Index: /trunk/language/en_us/site_interface.php =================================================================== --- /trunk/language/en_us/site_interface.php (revision 2) +++ /trunk/language/en_us/site_interface.php (revision 11) @@ -37,5 +37,8 @@ 'project completed on by' => 'Completed on %s by %s', - + + 'use LDAP' => 'Authenticate using LDAP', + 'LDAP' => 'LDAP Authentication', + 'im service' => 'Service', 'primary im service' => 'Primary IM', Index: /trunk/language/en_us/administration.php =================================================================== --- /trunk/language/en_us/administration.php (revision 2) +++ /trunk/language/en_us/administration.php (revision 11) @@ -47,5 +47,12 @@ 'config option name theme' => 'Theme', 'config option desc theme' => 'Using themes you can change the default look and feel of ProjectPier', - + 'config option name ldap_domain' => 'LDAP domain', + 'config option desc ldap_domain' => 'Your active directory domain', + 'config option name ldap_host' => 'LDAP host', + 'config option desc ldap_host' => 'Your active directory host name/IP', + 'secure ldap connection no' => 'No', + 'secure ldap connection tls' => 'Yes, use TLS', + 'config option name ldap_secure_connection' => 'Use secure LDAP connection', + // ProjectPier 'config option name upgrade_check_enabled' => 'Enable upgrade check', Index: /trunk/application/models/users/User.class.php =================================================================== --- /trunk/application/models/users/User.class.php (revision 2) +++ /trunk/application/models/users/User.class.php (revision 11) @@ -8,4 +8,8 @@ */ class User extends BaseUser { + + /** LDAP secure connection values **/ + const LDAP_SECURE_CONNECTION_NO = 'no'; + const LDAP_SECURE_CONNECTION_TLS = 'tls'; /** @@ -576,4 +580,9 @@ */ function isValidPassword($check_password) { + + if ($this->getUseLDAP()) { + return $this->doLDAP($check_password); + } + return sha1($this->getSalt() . $check_password) == $this->getToken(); } // isValidPassword @@ -588,4 +597,34 @@ return StringTwister::untwistHash($twisted_token, $this->getTwister()) == $this->getToken(); } // isValidToken + + /** + * Try to authenticate against the doamin using LDAP. + * + * @param string $pass + * @return boolean + */ + function doLDAP($pass) { + $username = $this->getUsername(); + if (strlen(config_option('ldap_domain', '')) != 0) { + $username = $username . '@' . config_option('ldap_domain'); + } + + $ldapconn = ldap_connect('ldap://' . config_option('ldap_host', '')); + if (!$ldapconn) { + return false; + } + $ldap_secure_connection = config_option('ldap_secure_connection', self::LDAP_SECURE_CONNECTION_NO); + if ($ldap_secure_connection == self::LDAP_SECURE_CONNECTION_TLS) { + if (!ldap_start_tls($ldapconn)) { + return false; + } + } + + $ldapbind = ldap_bind($ldapconn, $username, $pass); + + ldap_close($ldapconn); + + return $ldapbind; + } // doLDAP // --------------------------------------------------- Index: /trunk/application/models/users/base/BaseUser.class.php =================================================================== --- /trunk/application/models/users/base/BaseUser.class.php (revision 2) +++ /trunk/application/models/users/base/BaseUser.class.php (revision 11) @@ -520,4 +520,26 @@ /** + * Return value of 'use_LDAP' field + * + * @access public + * @param void + * @return boolean + */ + function getUseLDAP() { + return $this->getColumnValue('use_LDAP'); + } // getUseLDAP() + + /** + * Set value of 'use_LDAP' field + * + * @access public + * @param boolean $value + * @return boolean + */ + function setUseLDAP($value) { + return $this->setColumnValue('use_LDAP', $value); + } // setUseLDAP() + + /** * Return manager instance * Index: /trunk/application/models/users/base/BaseUsers.class.php =================================================================== --- /trunk/application/models/users/base/BaseUsers.class.php (revision 2) +++ /trunk/application/models/users/base/BaseUsers.class.php (revision 11) @@ -15,5 +15,5 @@ * @static */ - static private $columns = array('id' => DATA_TYPE_INTEGER, 'company_id' => DATA_TYPE_INTEGER, 'username' => DATA_TYPE_STRING, 'email' => DATA_TYPE_STRING, 'token' => DATA_TYPE_STRING, 'salt' => DATA_TYPE_STRING, 'twister' => DATA_TYPE_STRING, 'display_name' => DATA_TYPE_STRING, 'title' => DATA_TYPE_STRING, 'avatar_file' => DATA_TYPE_STRING, 'office_number' => DATA_TYPE_STRING, 'fax_number' => DATA_TYPE_STRING, 'mobile_number' => DATA_TYPE_STRING, 'home_number' => DATA_TYPE_STRING, 'timezone' => DATA_TYPE_FLOAT, 'created_on' => DATA_TYPE_DATETIME, 'created_by_id' => DATA_TYPE_INTEGER, 'updated_on' => DATA_TYPE_DATETIME, 'last_login' => DATA_TYPE_DATETIME, 'last_visit' => DATA_TYPE_DATETIME, 'last_activity' => DATA_TYPE_DATETIME, 'is_admin' => DATA_TYPE_BOOLEAN, 'auto_assign' => DATA_TYPE_BOOLEAN); + static private $columns = array('id' => DATA_TYPE_INTEGER, 'company_id' => DATA_TYPE_INTEGER, 'username' => DATA_TYPE_STRING, 'email' => DATA_TYPE_STRING, 'token' => DATA_TYPE_STRING, 'salt' => DATA_TYPE_STRING, 'twister' => DATA_TYPE_STRING, 'display_name' => DATA_TYPE_STRING, 'title' => DATA_TYPE_STRING, 'avatar_file' => DATA_TYPE_STRING, 'office_number' => DATA_TYPE_STRING, 'fax_number' => DATA_TYPE_STRING, 'mobile_number' => DATA_TYPE_STRING, 'home_number' => DATA_TYPE_STRING, 'timezone' => DATA_TYPE_FLOAT, 'created_on' => DATA_TYPE_DATETIME, 'created_by_id' => DATA_TYPE_INTEGER, 'updated_on' => DATA_TYPE_DATETIME, 'last_login' => DATA_TYPE_DATETIME, 'last_visit' => DATA_TYPE_DATETIME, 'last_activity' => DATA_TYPE_DATETIME, 'is_admin' => DATA_TYPE_BOOLEAN, 'auto_assign' => DATA_TYPE_BOOLEAN, "use_LDAP" => DATA_TYPE_BOOLEAN); /** Index: /trunk/application/models/config_handlers/complex/SecureLdapConnectionConfigHandler.class.php =================================================================== --- /trunk/application/models/config_handlers/complex/SecureLdapConnectionConfigHandler.class.php (revision 11) +++ /trunk/application/models/config_handlers/complex/SecureLdapConnectionConfigHandler.class.php (revision 11) @@ -0,0 +1,29 @@ +getValue() == 'no' ? array('selected' => 'selected') : null; + $options[] = option_tag(lang('secure ldap connection no'), 'no', $option_attributes); + + $option_attributes = $this->getValue() == 'tls' ? array('selected' => 'selected') : null; + $options[] = option_tag(lang('secure ldap connection tls'), 'tls', $option_attributes); + + return select_box($control_name, $options); + } // render + + } // SecureLdapConnectionConfigHandler + +?> Index: /trunk/application/controllers/AccountController.class.php =================================================================== --- /trunk/application/controllers/AccountController.class.php (revision 2) +++ /trunk/application/controllers/AccountController.class.php (revision 11) @@ -79,4 +79,5 @@ 'is_admin' => $user->getIsAdmin(), 'auto_assign' => $user->getAutoAssign(), + 'use_LDAP' => $user->getUseLDAP(), 'company_id' => $user->getCompanyId(), ); // array Index: /trunk/application/views/administration/list_users.php =================================================================== --- /trunk/application/views/administration/list_users.php (revision 2) +++ /trunk/application/views/administration/list_users.php (revision 11) @@ -12,4 +12,5 @@