From: Kurt Zeilenga Date: Tue, 14 Dec 2010 18:17:28 +0000 (+0000) Subject: Use ldap_parse_whoami X-Git-Tag: MIGRATION_CVS2GIT~359 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0ba7be7a6fbc9bf024e60929fd361beeb8073b90;p=openldap Use ldap_parse_whoami --- diff --git a/clients/tools/ldapwhoami.c b/clients/tools/ldapwhoami.c index ea312c61b2..7cf1466b73 100644 --- a/clients/tools/ldapwhoami.c +++ b/clients/tools/ldapwhoami.c @@ -111,8 +111,7 @@ main( int argc, char *argv[] ) int rc; LDAP *ld = NULL; char *matcheddn = NULL, *text = NULL, **refs = NULL; - char *retoid = NULL; - struct berval *retdata = NULL; + struct berval *authzid = NULL; int id, code = 0; LDAPMessage *res; LDAPControl **ctrls = NULL; @@ -182,7 +181,8 @@ main( int argc, char *argv[] ) goto skip; } - rc = ldap_parse_extended_result( ld, res, &retoid, &retdata, 1 ); + rc = ldap_parse_whoami( ld, res, &authzid ); + ldap_msgfree(res); if( rc != LDAP_SUCCESS ) { tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL ); @@ -190,11 +190,11 @@ main( int argc, char *argv[] ) goto skip; } - if( retdata != NULL ) { - if( retdata->bv_len == 0 ) { + if( authzid != NULL ) { + if( authzid->bv_len == 0 ) { printf(_("anonymous\n") ); } else { - printf("%s\n", retdata->bv_val ); + printf("%s\n", authzid->bv_val ); } } @@ -228,8 +228,7 @@ skip: ber_memfree( text ); ber_memfree( matcheddn ); ber_memvfree( (void **) refs ); - ber_memfree( retoid ); - ber_bvfree( retdata ); + ber_bvfree( authzid ); /* disconnect from server */ tool_unbind( ld );