我不知道如何获取AD中的用户唯一标识符(SID)。代码片段:PHP LDAP获取用户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-......
?
从谷歌搜索的第2个链接 'PHP LDAP获得SID' 扔了一些代码值得尝试:http://php.net/manual/en/function.ldap-get-values-len。 php(请参阅derek dot ethier的评论)&http://l3rady.com/index.html%3Fp=435.html –
向“''$ attributes'''数组添加一个”+“,看看结果然后。这可能会揭示一些额外的信息。 – heiglandreas