function get_group_list() { global $config; $ldap_groups = array(); // show all Active Directory Users by default $default_group = 'Users'; if (isset($config['auth_ad_group'])) { if ($config['auth_ad_group'] !== $default_group) { $ldap_groups[] = $config['auth_ad_group']; } } if (!isset($config['auth_ad_groups']) && !isset($config['auth_ad_group'])) { $ldap_groups[] = get_dn($default_group); } foreach ($config['auth_ad_groups'] as $key => $value) { $ldap_groups[] = get_dn($key); } return $ldap_groups; }
function my_ldap_auth($uid, $passwd) { global $authmethods; if (!isset($authmethods['ldap']['server_address']) || !isset($authmethods['ldap']['search_group'])) { displayerror("Please specify LDAP authentication settings completely"); } $ds = @ldap_connect($authmethods['ldap']['server_address']); @ldap_bind($ds); $dn = get_dn($uid, $ds); @ldap_unbind($ds); $ds = @ldap_connect($authmethods['ldap']['server_address']); if ($dn != false && ldap_bind($ds, $dn, $passwd) && $passwd != '') { return TRUE; } else { return FALSE; } }