drpjdfj618393 2012-11-01 21:21
浏览 148
已采纳

获取特定组内的用户列表

I am trying to query a list of users within a specific active directory group using PHP and LDAP.

I am making the connection and bind as normal:

$connection = ldap_connect($hostname);
$bind = ldap_bind($connection, $username, $password);

For this example, the name of the group I need to acquire the list of users from is "Test Group". There is also a OU of "LDAPTest".

I have tried all of the following, plus a bunch of other ways, and I am just not finding the method to get all of the users within the group "Test Group", which has four users that have been added to it.

$result = ldap_search($connection,"OU=LDAPTest,DC=example,DC=net", "(CN=*)");
$result = ldap_search($connection,"OU=LDAPTest,DC=example,DC=net", "memberOf=Test Group");
$result = ldap_search($connection,"memberOf=Test Group,DC=example,DC=net", "CN=*");
$result = ldap_search($connection,"memberOf=Test Group,DC=example,DC=net", "CN=*");
  • 写回答

1条回答 默认 最新

  • douyoufan7881 2012-11-02 09:23
    关注

    Assuming your Test Group is in the LDAPTest OU, you can get the group record (which will include its members) with something like this:

    $search = ldap_search($connection, "OU=LDAPTest,DC=example,DC=net", "(&(objectClass=group)(cn=Test Group))");
    

    Note that the user you perform the bind with needs to have access to this group (and to view its members).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。