2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2003 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>.
19 #include <ac/stdlib.h>
20 #include <ac/string.h>
26 * LDAP Who Am I? (Extended) Operation <draft-zeilenga-ldap-authzid-xx.txt>
29 int ldap_parse_whoami(
32 struct berval **authzid )
38 assert( LDAP_VALID( ld ) );
39 assert( res != NULL );
40 assert( authzid != NULL );
44 rc = ldap_parse_extended_result( ld, res, &retoid, authzid, 0 );
46 if( rc != LDAP_SUCCESS ) {
47 ldap_perror( ld, "ldap_parse_whoami" );
51 ber_memfree( retoid );
56 ldap_whoami( LDAP *ld,
64 assert( LDAP_VALID( ld ) );
65 assert( msgidp != NULL );
67 rc = ldap_extended_operation( ld, LDAP_EXOP_X_WHO_AM_I,
68 NULL, sctrls, cctrls, msgidp );
76 struct berval **authzid,
78 LDAPControl **cctrls )
84 rc = ldap_whoami( ld, sctrls, cctrls, &msgid );
85 if ( rc != LDAP_SUCCESS ) return rc;
87 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) {
91 rc = ldap_parse_whoami( ld, res, authzid );
92 if( rc != LDAP_SUCCESS ) {
97 return( ldap_result2error( ld, res, 1 ) );