2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2004 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This program was orignally developed by Kurt D. Zeilenga for inclusion in
23 #include <ac/stdlib.h>
24 #include <ac/string.h>
30 * LDAP Who Am I? (Extended) Operation <draft-zeilenga-ldap-authzid-xx.txt>
33 int ldap_parse_whoami(
36 struct berval **authzid )
42 assert( LDAP_VALID( ld ) );
43 assert( res != NULL );
44 assert( authzid != NULL );
48 rc = ldap_parse_extended_result( ld, res, &retoid, authzid, 0 );
50 if( rc != LDAP_SUCCESS ) {
51 ldap_perror( ld, "ldap_parse_whoami" );
55 ber_memfree( retoid );
60 ldap_whoami( LDAP *ld,
68 assert( LDAP_VALID( ld ) );
69 assert( msgidp != NULL );
71 rc = ldap_extended_operation( ld, LDAP_EXOP_X_WHO_AM_I,
72 NULL, sctrls, cctrls, msgidp );
80 struct berval **authzid,
82 LDAPControl **cctrls )
88 rc = ldap_whoami( ld, sctrls, cctrls, &msgid );
89 if ( rc != LDAP_SUCCESS ) return rc;
91 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) {
95 rc = ldap_parse_whoami( ld, res, authzid );
96 if( rc != LDAP_SUCCESS ) {
101 return( ldap_result2error( ld, res, 1 ) );