Commit b0e3da7a authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Import cancel and passwd

parent b5dc1383
......@@ -11,23 +11,21 @@ PROGRAMS = apitest dntest ftest ltest
SRCS = bind.c open.c result.c error.c compare.c search.c \
controls.c messages.c references.c extended.c cyrus.c \
modify.c add.c modrdn.c delete.c abandon.c cache.c \
sasl.c sbind.c kbind.c unbind.c \
sasl.c sbind.c kbind.c unbind.c cancel.c \
filter.c free.c sort.c passwd.c whoami.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c os-ip.c url.c sortctrl.c vlvctrl.c \
init.c options.c print.c string.c util-int.c schema.c \
charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c \
cancel.c
charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
controls.lo messages.lo references.lo extended.lo cyrus.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \
sasl.lo sbind.lo kbind.lo unbind.lo \
sasl.lo sbind.lo kbind.lo unbind.lo cancel.lo \
filter.lo free.lo sort.lo passwd.lo whoami.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo \
cancel.lo
charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
......
/* $OpenLDAP$ */
/*
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/*
* LDAPv3 Cancel Operation Request
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
#include "ldap_log.h"
#ifdef LDAP_EXOP_X_CANCEL
int
ldap_cancel(
LDAP *ld,
int cancelid,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp )
{
BerElement *cancelidber = NULL;
struct berval *cancelidvalp = NULL;
int rc;
cancelidber = ber_alloc_t( LBER_USE_DER );
ber_printf( cancelidber, "{i}", cancelid );
ber_flatten( cancelidber, &cancelidvalp );
rc = ldap_extended_operation( ld, LDAP_EXOP_X_CANCEL,
cancelidvalp, sctrls, cctrls, msgidp );
ber_free( cancelidber, 1 );
return rc;
}
int
ldap_cancel_s(
LDAP *ld,
int cancelid,
LDAPControl **sctrls,
LDAPControl **cctrls )
{
BerElement *cancelidber = NULL;
struct berval *cancelidvalp = NULL;
int rc;
cancelidber = ber_alloc_t( LBER_USE_DER );
ber_printf( cancelidber, "{i}", cancelid );
ber_flatten( cancelidber, &cancelidvalp );
rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_CANCEL,
cancelidvalp, sctrls, cctrls, NULL, NULL );
ber_free( cancelidber, 1 );
return rc;
}
#endif /* LDAP_EXOP_X_CANCEL */
/* $OpenLDAP$ */
/*
* Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
/*
* LDAP Password Modify (Extended) Operation <RFC 3???>
*/
int ldap_parse_passwd(
LDAP *ld,
LDAPMessage *res,
struct berval **newpasswd )
{
int rc;
char *retoid = NULL;
struct berval *retdata;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( res != NULL );
assert( newpasswd != NULL );
*newpasswd = NULL;
rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 0 );
if( rc != LDAP_SUCCESS ) {
return rc;
}
if( retdata != NULL ) {
ber_tag_t tag;
BerElement *ber = ber_init( retdata );
if( ber == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return ld->ld_errno;
}
/* we should check the tag */
tag = ber_scanf( ber, "{o}", newpasswd );
ber_free( ber, 1 );
if( tag == LBER_ERROR ) {
rc = ld->ld_errno = LDAP_DECODING_ERROR;
}
}
ber_memfree( retoid );
return rc;
}
int
ldap_passwd( LDAP *ld,
struct berval *user,
struct berval *oldpw,
struct berval *newpw,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp )
{
int rc;
struct berval bv = {0, NULL};
BerElement *ber = NULL;
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( msgidp != NULL );
if( user != NULL || oldpw != NULL || newpw != NULL ) {
/* build change password control */
ber = ber_alloc_t( LBER_USE_DER );
if( ber == NULL ) {
ld->ld_errno = LDAP_NO_MEMORY;
return ld->ld_errno;
}
ber_printf( ber, "{" /*}*/ );
if( user != NULL ) {
ber_printf( ber, "ts",
LDAP_TAG_EXOP_MODIFY_PASSWD_ID, user );
}
if( oldpw != NULL ) {
ber_printf( ber, "ts",
LDAP_TAG_EXOP_MODIFY_PASSWD_OLD, oldpw );
}
if( newpw != NULL ) {
ber_printf( ber, "ts",
LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, newpw );
}
ber_printf( ber, /*{*/ "N}" );
rc = ber_flatten2( ber, &bv, 0 );
if( rc < 0 ) {
ld->ld_errno = LDAP_ENCODING_ERROR;
return ld->ld_errno;
}
}
rc = ldap_extended_operation( ld, LDAP_EXOP_MODIFY_PASSWD,
bv.bv_val ? &bv : NULL, sctrls, cctrls, msgidp );
ber_free( ber, 1 );
return rc;
}
int
ldap_passwd_s(
LDAP *ld,
struct berval *user,
struct berval *oldpw,
struct berval *newpw,
struct berval **newpasswd,
LDAPControl **sctrls,
LDAPControl **cctrls )
{
int rc;
int msgid;
LDAPMessage *res;
rc = ldap_passwd( ld, user, oldpw, newpw, sctrls, cctrls, &msgid );
if ( rc != LDAP_SUCCESS ) {
return rc;
}
if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) {
return ld->ld_errno;
}
rc = ldap_parse_passwd( ld, res, newpasswd );
if( rc != LDAP_SUCCESS ) {
ldap_msgfree( res );
return rc;
}
return( ldap_result2error( ld, res, 1 ) );
}
# $OpenLDAP$
## Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
## Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
##
## Makefile.in for LDAP -lldap
......@@ -14,7 +14,7 @@ XXSRCS = apitest.c test.c \
controls.c messages.c references.c extended.c cyrus.c \
modify.c add.c modrdn.c delete.c abandon.c cache.c \
sasl.c sbind.c kbind.c unbind.c \
filter.c free.c sort.c \
filter.c free.c sort.c passwd.c whoami.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c os-ip.c url.c sortctrl.c vlvctrl.c \
init.c options.c print.c string.c util-int.c schema.c \
......@@ -29,7 +29,7 @@ OBJS = threads.lo rdwr.lo tpool.lo \
controls.lo messages.lo references.lo extended.lo cyrus.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \
sasl.lo sbind.lo kbind.lo unbind.lo \
filter.lo free.lo sort.lo \
filter.lo free.lo sort.lo passwd.lo whoami.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment