【发布时间】:2016-09-16 14:07:39
【问题描述】:
我不知道如何在 AD 中获取用户唯一标识符 (SID)。代码片段:
...
$filter="(&(samaccountname=".$this->username.")(memberOf:1.2.840.113556.1.4.1941:=CN=GROUP_NAME,OU=Security,DC=something,DC=something))";
$attribute = array("cn","objectsid","description", "group", "member", "samaccountname");
$sr=ldap_search($this->conn_ldap, $this->ldap_dn, $filter, $attribute);
if ($sr)
{
$this->info = ldap_get_entries($this->conn_ldap, $sr);
if ($this->info["count"] == 1){
ldap_close($this->conn_ldap);
return true;
}
...
我可以通过以下方式获取信息:
echo $this->info[0]["cn"][0];
或
echo $this->info[0]["objectsid"][0];
在第一个输出中,我可以在第二个中看到用户名,例如 0�@�d^�WL7�U
我相信sid应该像S-......?
【问题讨论】:
-
谷歌搜索“PHP ldap get SID”的前 2 个链接抛出了一些值得尝试的代码:php.net/manual/en/function.ldap-get-values-len.php(参见 derek dot ethier 的评论)和l3rady.com/index.html%3Fp=435.html
-
在
$attributes-array 中添加一个“+”,然后查看结果中的内容。这可能会揭示一些额外的信息。
标签: php active-directory ldap