以下是我的 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
执行时
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
这里data后面的字符串52e代表扩展错误。
任何人都可以建议我如何直接访问此扩展错误。目前我正在解析字符串以提取该值。通常,当我打印 LDAP_OPT_ERROR_NUMBER 时,它仅返回 49(INVALID_CREDENTIALS) 但这对我来说还不够。如何获取扩展错误的代码(仅代码)。
我什至尝试打印 ld->ld_errno 但它不允许我,因为没有内存分配给 ld。
最佳答案
您必须解析错误字符串才能提取错误号,因为您无法从 LDAP 结构中看到错误代码,因为它是不透明数据类型
并且您可以访问的元素>LDAP结构
只能通过例程
才能看到不完整的结构定义。
关于ldap - LDAP 中的扩展 errno,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15217144/