Reputation: 3090
Following are the lines of my code in C:
ldap_bind_s(ld, root_dn, root_pw, auth_method) != LDAP_SUCCESS
ldap_perror( ld, "ldap_bind" );//to print the EXACT error like 525,52e
When executed
Project ./a.out CN=username,OU=ABC,DC=example,DC=com wrong-pasword
ldap_bind: Invalid credentials (49)
additional info: 80090308: LdapErr: DSID-0C090334, comment:
AcceptSecurityContext error, data 52e, vece
Here the string 52e after data represents the extended error.
Can anyone please suggest how do I access this extended error directly. Currently I am parsing the string to extract this value. Normally when I print LDAP_OPT_ERROR_NUMBER it returns just 49(INVALID_CREDENTIALS) but that is not sufficient for me. How do I get the code(only code) of extended error.
I even tried printing ld->ld_errno but it is not allowing me since no memory has been alloted to ld.
Upvotes: 2
Views: 318
Reputation: 987
You have to parse error string in order to extract error number,as you are unable to to see the error code from LDAP structure,because it is opaque datatype
and you can access element of LDAP structure
only through routines
which can see the incomplete definition of structure.
Upvotes: 2