Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取所有用户';使用PHP通过LDAP从AD中删除组_Php_Search_Active Directory_Ldap - Fatal编程技术网

获取所有用户';使用PHP通过LDAP从AD中删除组

获取所有用户';使用PHP通过LDAP从AD中删除组,php,search,active-directory,ldap,Php,Search,Active Directory,Ldap,我正在尝试使用PHP获取用户所属的所有组。我能够抓取memberof属性中列出的所有组,但不能抓取用户继承的组 我已经尝试修改代码以同时对组名/samaccount名称进行ldap\u搜索,但在搜索组的memberof属性时没有成功 下面是我正在使用的代码 $checkDn=$this->setDn(true); $results[0]=$attribute; // We need to search for this user in order to get their entry

我正在尝试使用PHP获取用户所属的所有组。我能够抓取memberof属性中列出的所有组,但不能抓取用户继承的组

我已经尝试修改代码以同时对组名/samaccount名称进行ldap\u搜索,但在搜索组的memberof属性时没有成功

下面是我正在使用的代码

$checkDn=$this->setDn(true); 
$results[0]=$attribute; 

// We need to search for this user in order to get their entry.
$this->result=@ldap_search($this->connection,$checkDn,$this->getUserIdentifier()."=$uname",$results);
$info=ldap_get_entries($this->connection, $this->result);

// Only one entry should ever be returned(no user will have the same uid) 
$entry=ldap_first_entry($this->connection, $this->result);

if(!$entry){
 $this->ldapErrorCode=-1;
 $this->ldapErrorText="Couldn't find user";
 return false; // Couldn't find the user...
}

// Get all the member DNs
if(!$values=@ldap_get_values($this->connection,$entry,$attribute)){
 $this->ldapErrorCode=ldap_errno($this->connection);
 $this->ldapErrorText=ldap_error($this->connection);
 return false; // No matching attributes 
}

// Return an array containing the attributes. 
return $values; 
这是他们所属的一个样本组

CN=Business Operations,OU=Groups,OU=Operations,OU=Corporate,OU=company name,DC=website,DC=com
谢谢你的帮助