- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我知道我的错误将是非常简单的,但我试图找到问题所在但我没有看到它,也许你可以帮助我....
我正在尝试使用 php 创建一个函数,这样我就可以连接到 LDAP 并找到所需的信息。
我的 php 代码如下:
$ldapconfig['host'] = "127.0.0.1";
$ldapconfig['port'] = NULL;
$ldapconfig['basedn'] = "dc=example,dc=com";
$ldapconfig['binddn'] = "user";
$ldapconfig['bindpw'] = "password";
function ldap_authenticate($user, $pass) {
global $ldapconfig;
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
if ($user != "" && $pass != "") {
$ds=ldap_connect($ldapconfig['host'],$ldapconfig['port']);
if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
return NULL;
}
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
$r = ldap_search( $ds, $ldapconfig['basedn'], 'sAMAccountName=' . $user);
if ($r) {
$result = ldap_get_entries( $ds, $r);
if ($result[0]) {
if (ldap_bind( $ds, $result[0]['dn'], $pass) ) {
return $result[0]['mail'][0];
}
}
}
}
return NULL;
当我尝试运行代码时,出现以下错误:ldap_bind 行 xxxx 上的无效 DN 语法该行如下:
ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
最佳答案
如错误中所述,您的绑定(bind) DN 格式错误。 DN 代表对象的完整路径 - 所以在你的情况下应该是这样的(看起来你在 AD 上?)
"cn=用户名,ou=域用户,dc=example,dc=com"
根据您的 LDAP 风格(Active Directory、OpenLDAP 等),您可能能够使用 uid(因此只是“用户名”)进行绑定(bind),但最好假设您总是需要完整的 DN。
您可以使用像 Apache Directory Studio 这样的 LDAP 工具帮助构建查询并找出对象的 DN。或者有 ldp.exe也是(前提是它是 AD),但是 directory studio 更容易使用。
关于php - LDAP 问题,ldap_bind 无效的 dn 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13487225/
当我查找 DN 时带 Spring ldapTemplate , 我必须省略配置的基本 DN。 例如,当基本 DN 配置为 dc=company,dc=com 时,工作查找就像 ldapTemplat
在我的 LDAP 客户端程序中,有时我必须在搜索过滤器中包含 DN 值。但是这个 DN 经常变化,每次我都必须在我的代码中更改这个过滤器。 当我用谷歌搜索它时,我得到了这样的东西 假设您想从 R&D
如何在javascript中写一个必须遵循条件的正则表达式 DN 地址中的所有段都应遵循 cn=,ou=,o=,o=swift 序列 所有段都应该用,分隔. DN 地址最多应包含 100 个字符。 不
我最近在代码中遇到了这一行 - fprintf(logfile," |-IP Version : %dn",(unsigned int)iph->version); 这里的“%dn”
在我们的应用程序中,我们为平台和用户等内部实体生成证书。我们的内部实体由自定义 DN 标识: 平台 DN:p=平台名称 用户DN:cn=userName,p=platformName 我们尝试使用 o
我完全陷入了如何使用新值更新CSV文件中的多行的问题。问题如下,我将一个 Activity 目录csv导出文件导入了大约有500个用户的powershell中,如下所示: $Users = Impor
我进行了 LDAP 目录搜索并收到了一些结果。我需要迭代这些结果并显示每个条目的 Dn。 在我的测试环境中,我通过获取entryDN属性的值来返回Dn值。 在生产环境中,entryDN 属性始终返回
我目前在搜索 DN 包含逗号的条目时遇到问题: StringTokenizer st = new StringTokenizer(dn, "="); Attributes searchAttribut
我用下面的代码有两个目标 1) 获取属于特定广告组的用户列表 2) 获取属于该组的所有用户的电子邮件/姓氏/名字 如果有更好的方法来实现这两个目标,请告诉我。 我能够获得完整的 DN,但我不确定如何从
我想要一个正则表达式来验证所有可能的 DN 类型 我创造了一个,但它不是很好。 /([A-z0-9=]{1}[A-z0-9]{1})*[,??]/ 和其他一些 通过更改它,但徒劳无功。 可能的 DN
我有一个九节点 Cassandra 集群,一切似乎都运行良好,除了我的两台服务器相互显示为 DN。集群中的所有其他节点将所有节点显示为 UN。这两个显示除彼此之外的所有节点 UN,其中它们彼此显示为
我知道以前有人回答过这个问题,但它无法帮助我(除非它有帮助,但由于我的 php 知识有限,它没有帮助)。下面是我的代码: >Could not connect to LDAP server
我已经很清楚如何在 GRPC++ 中建立双向认证的 SSL 通信,但现在我希望在建立的 TLS 通信中获得获取 SSL 客户端 DN 的方式,以进行进一步的身份状态分类。 如果您有一些建议,谢谢。 最
什么是使用 python 获取 SSL 的主题 DN 的好方法? 这包括以下内容: 国名 州名 地区名称 组织名称 通用名 最佳答案 就像是: import ssl import socket fro
我目前正在为我的公司编写一个工具(在 ANSI C 中),它从 LDAP 目录中读取并以特定格式(即:我们旧的专有目录 db 的名称格式)输出所有数据。 然后由另一个工具处理,该工具读取输出等等...
我正在尝试对位于目录根目录的许多不同 OU 执行 LDAP 搜索。 上下文初始化: Hashtable env = new Hashtable(); env.put(Context.SECURITY_
我如何为 LDAP 搜索制作 bourne shell 代码以不返回 DN 而只返回 CN?我为此使用 iTerm2。 最佳答案 如果您只想查看 cn结果,然后您可以使用以下内容: ldapsearc
您好我正在尝试使用我的 ldap 测试服务器来验证 openca 中的用户。 我目前正在通过 phpldapadmin 连接: Login DN : cn=admin,dc=example,dc=co
我构建了一些假设 LDAP DN 不区分大小写的功能。 我已经使用 ActiveDirectory、Oracle 和 OpenLDAP 对其进行了检查,并且不区分大小写。 是否适用于所有 LDAP?
我知道你不能简单地过滤 dn,但我有这样的东西: dc=lvl3,dc=lvl2,dc=lvl1,有人可能有这样的 dn:CN=Last, First,OU=ou1,OU=retired,OU=ou1
我是一名优秀的程序员,十分优秀!