[英]PHP LDAP Get Members of a group
是否可以仅在PHP中获得LDAP组的成员?
我已经搜索了一下Google,但只发现了复杂的解决方案。 我只需要名称,仅此而已。
$dn = "o=my_company, c=CH";
$filter="(|(sn=$person*)(vorname=$person*))";
$justthese = array( "ou", "sn", "vorname", "mail");
用户在具有UID的组中列出
我已经找到了类似的东西,但是却无济于事。 希望您能帮助我,如果您需要更多信息,请告诉我
根据注释中的其他信息,您不能在单个LDAP查询中执行此操作。
这是一个可能的解决方案的概述-我为编写的LDAP邮件列表管理器使用了类似的方法。 (这是PHP 7语法。)
// Setup and run LDAP Search
$dn = "cn=groups,o=my_company,c=CH"; // Location of groups in directory
$attributes = ['members'];
$filter = sprintf("(groupName=%s)", $group_name);
$search = ldap_search($conn, $dn, $filter, $attributes);
$results = ldap_get_entries($conn, $search);
// Function to call on each member
$member_func = function($uid)
{
// This is a helper that will get the user data and return an appropriate object (or string).
// Implementation is left as an exercise to the user
return get_user_details($uid);
};
// Need to filter LDAP results for actual values only
$member_data = array_map($member_func, array_filter($results['members'], function($k) { return is_numeric($k); }, ARRAY_FILTER_USE_KEY));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.