public function __construct($host = UL_LDAP_DEFAULT_HOST, $port = UL_LDAP_DEFAULT_PORT, $enc = UL_LDAP_DEFAULT_ENCRYPTION) { $constr = "{$host}:{$port}"; if ($enc == 'SSL') { if (!ulUtils::BeginsWith($host, 'ldaps:')) { $constr = "ldaps://{$constr}"; } } else { if (!ulUtils::BeginsWith($host, 'ldaps:')) { $constr = "ldap://{$constr}"; } } $this->con = ldap_connect($constr, $port); if ($this->con === false) { return; } if (!ldap_set_option($this->con, LDAP_OPT_PROTOCOL_VERSION, 3)) { $this->Fail(); } if (!ldap_set_option($this->con, LDAP_OPT_REFERRALS, 0)) { $this->Fail(); } if ($enc == 'TLS' && !ldap_start_tls($this->con)) { $this->Fail(); } }
private static function GetSaltFromHash($hash) { if (ulUtils::BeginsWith($hash, '{SSHA}')) { $hash = base64_decode(substr($hash, 6)); return '{SSHA}' . substr($hash, 20); } else { if (ulUtils::BeginsWith($hash, '{SHA}')) { return '{SHA}'; } else { if (ulUtils::BeginsWith($hash, '{SMD5}')) { $hash = base64_decode(substr($hash, 6)); return '{SMD5}' . substr($hash, 16); } else { if (ulUtils::BeginsWith($hash, '{MD5}')) { return '{MD5}'; } else { if (ulUtils::BeginsWith($hash, '{CRYPT}')) { $hash = substr($hash, 7); return '{CRYPT}' . substr($hash, 0, 29); } else { if (ulUtils::BeginsWith($hash, '{PBKDF2}')) { $parts = explode(':', $hash); array_pop($parts); return implode(':', $parts); } else { return substr($hash, 0, 29); } } } } } } }