I am using Pandora 4.0 and there doesn't seem to be an option for Active Directory and LDAP doesn't seem to work. The features page (http://pandorafms.com/index.php?sec=pandora&sec2=features) indicates that Active Directory is supported in both community and Enterprise versions of Pandora. Is Active Directory only available in the Enterprise version? Is there something else I need to do to get LDAP working?
LDAP and Active Directory
rich.anderson · 10 oct 2011, 22:14 · 6 mensajes · 259 visitas
- Inicio del debate
I have learned that Active Directory only works on the Enterprise version. In the meantime, has anyone gotten LDAP to work?
We have modified the include/auth/mysql.php file to allow ldap from active directory (Windows 2008 R2). Commented out this line: if (strlen($password) == 0 || !@ldap_bind ($ds, $config["ldap_login_attr"]."=".$login.",".$config["ldap_base_dn"], $password)) { And we replaced it with this one: if (strlen($password) == 0 || !@ldap_bind ($ds, $login."@my.domain.com", $password)) This could be better, and much of the ldap configuration in the web interface is non-functioning, but this works for our needs.
Yeah I had to do something similar. Ended up rewriting a good part of the "ldap_process_user_login" function so it would work with my LDAP service.
function ldap_process_user_login ($login, $password) { global $config, $filter; if (! function_exists ("ldap_connect")) { $config["auth_error"] = __('Your installation of PHP does not support LDAP'); return false; } // Connect to the LDAP server $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); if (!$ds) { $config["auth_error"] = 'Error connecting to LDAP server'; return false; } // Set the LDAP version ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); if ($config["ldap_start_tls"]) { if (!@ldap_start_tls ($ds)) { $config["auth_error"] = 'Could not start TLS for LDAP connection'; @ldap_close ($ds); return false; } } $ldap_login_attr = isset($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) : ''; $ldap_base_dn = isset($config["ldap_base_dn"]) ? io_safe_output($config["ldap_base_dn"]) : ''; $login = isset($config["login"]) ? io_safe_output($login) : ''; //Filter out disabled, expired, non-user accounts and set login attributes $filter="(&(objectClass=user)(objectCategory=Person)($ldap_login_attr=$login)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; //Specify domain prefix ,replace DOMAIN.COM $bind = @ldap_bind($ds, "DOMAIN.COM\" . $login, $password); echo "nr" . $ldap_base_dn . "nr"; //Bind to verfiy user & password if ($bind) { //Search to ensure you only checking against the LDAP path specified in $ldap_login_attr $result = ldap_search($ds,$ldap_base_dn,$filter); if (!$result) { $config["auth_error"] = 'User not found in LDAP Search'; @ldap_close ($ds); return false; } } else { $config["auth_error"] = 'User not found in LDAP or incorrect password'; @ldap_close ($ds); return false; } @ldap_close ($ds); return true; }Just noticed a bug in the function editted and fixed it.
function ldap_process_user_login ($login, $password) { global $config, $filter, $ldap_result, $ldap_login; if (! function_exists ("ldap_connect")) { $config["auth_error"] = __('Your installation of PHP does not support LDAP'); return false; } // Connect to the LDAP server $ds = @ldap_connect ($config["ldap_server"], $config["ldap_port"]); if (!$ds) { $config["auth_error"] = 'Error connecting to LDAP server'; return false; } // Set the LDAP version ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, $config["ldap_version"]); if ($config["ldap_start_tls"]) { if (!@ldap_start_tls ($ds)) { $config["auth_error"] = 'Could not start TLS for LDAP connection'; @ldap_close ($ds); return false; } } $ldap_login_attr = isset($config["ldap_login_attr"]) ? io_safe_output($config["ldap_login_attr"]) : ''; $ldap_base_dn = isset($config["ldap_base_dn"]) ? io_safe_output($config["ldap_base_dn"]) : ''; $ldap_login = isset($config["login"]) ? io_safe_output($config["login"]) : ''; //Filter out disabled, expired, non-user accounts and set login attributes $filter="(&(objectClass=user)(objectCategory=Person)($ldap_login_attr=$login)(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))"; $bind = @ldap_bind($ds, "RETRO.COM\" . $login, $password); //Bind to verify user & password if ($bind) { //Search to ensure you're only checking against the LDAP base path specified in $ldap_login_attr $ldap_result = ldap_search($ds,$ldap_base_dn,$filter); if (!$ldap_result) { $config["auth_error"] = 'User not found in LDAP Search'; @ldap_close ($ds); return false; } } else { $config["auth_error"] = 'User not found in LDAP or incorrect password'; @ldap_close ($ds); return false; } @ldap_close ($ds); return true; }Hi Ethan, And how am I supposed to use this function? I've replaced it in my mysql.php, but still cannot login through LDAP. Kind regards.
Entra en tu cuenta para publicar.
