Skip to content
Snippets Groups Projects
Commit 4813e6fc authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

Use ldap_parse_whoami

parent 9fd7e512
No related branches found
No related tags found
No related merge requests found
...@@ -111,8 +111,7 @@ main( int argc, char *argv[] ) ...@@ -111,8 +111,7 @@ main( int argc, char *argv[] )
int rc; int rc;
LDAP *ld = NULL; LDAP *ld = NULL;
char *matcheddn = NULL, *text = NULL, **refs = NULL; char *matcheddn = NULL, *text = NULL, **refs = NULL;
char *retoid = NULL; struct berval *authzid = NULL;
struct berval *retdata = NULL;
int id, code = 0; int id, code = 0;
LDAPMessage *res; LDAPMessage *res;
LDAPControl **ctrls = NULL; LDAPControl **ctrls = NULL;
...@@ -182,19 +181,20 @@ main( int argc, char *argv[] ) ...@@ -182,19 +181,20 @@ main( int argc, char *argv[] )
goto skip; 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 ) { if( rc != LDAP_SUCCESS ) {
tool_perror( "ldap_parse_extended_result", rc, NULL, NULL, NULL, NULL ); tool_perror( "ldap_parse_whoami", rc, NULL, NULL, NULL, NULL );
rc = EXIT_FAILURE; rc = EXIT_FAILURE;
goto skip; goto skip;
} }
if( retdata != NULL ) { if( authzid != NULL ) {
if( retdata->bv_len == 0 ) { if( authzid->bv_len == 0 ) {
printf(_("anonymous\n") ); printf(_("anonymous\n") );
} else { } else {
printf("%s\n", retdata->bv_val ); printf("%s\n", authzid->bv_val );
} }
} }
...@@ -228,8 +228,7 @@ skip: ...@@ -228,8 +228,7 @@ skip:
ber_memfree( text ); ber_memfree( text );
ber_memfree( matcheddn ); ber_memfree( matcheddn );
ber_memvfree( (void **) refs ); ber_memvfree( (void **) refs );
ber_memfree( retoid ); ber_bvfree( authzid );
ber_bvfree( retdata );
/* disconnect from server */ /* disconnect from server */
tool_unbind( ld ); tool_unbind( ld );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment