我开发了一个Web应用程序Zend Framework-1.11。最初,我创建了用户帐户,并将其与XAMPP(MySQL)中的用户表链接。可以创建用户帐户并将其保存在数据库中。此外,每个用户都可以登录该应用程序。
C:\ xampp \ htdocs \ hrm_app \ index.php
$mysqlPDO = new PDO('mysql:host='.HRM_HOST.';dbname='.HRM_DBNAME.'',HRM_username,HRM_PASSWORD,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
C:\ xampp \ htdocs \ hrm_app \ public \ db_constants.php
但是,我想将应用程序与公司的active Directory帐户关联起来,以便用户可以使用其AD帐户而不是数据库中的帐户进行登录。我已经设置了所有这些参数,但是不知道如何实现我的目标。
C:\ xampp \ htdocs \ hrm_app \ Zend \ Ldap.php
public function setOptions($options){ if ($options instanceof Zend_Config) { $optiOns= $options->toArray(); } $permittedOptiOns= array( 'host' => 'ad.kkklimited.com','port' => 0,'useSsl' => false,'username' => 'testing','password' => '@Testing_12345#','bindRequiresDn' => false,'baseDn' => 'CN=Users,DC=ad,DC=kkklimited,DC=com','accountCanonicalForm' => null,'accountDomainName' => 'ad.kkklimited.com','accountDomainNameShort' => 'KKK','accountFilterFormat' => null,'allowEmptyPassword' => false,'useStartTls' => true,'optReferrals' => false,'tryusernameSplit' => true,); foreach ($permittedOptions as $key => $val) { if (array_key_exists($key,$options)) { $val = $options[$key]; unset($options[$key]); /* Enforce typing. This eliminates issues like Zend_Config_Ini * returning '1' as a string (ZF-3163). */ switch ($key) { case 'port': case 'accountCanonicalForm': $permittedOptions[$key] = (int)$val; break; case 'useSsl': case 'bindRequiresDn': case 'allowEmptyPassword': case 'useStartTls': case 'optReferrals': case 'tryusernameSplit': $permittedOptions[$key] = ($val === true || $val === '1' || strcasecmp($val,'true') == 0); break; default: $permittedOptions[$key] = trim($val); break; } } } if (count($options) > 0) { $key = key($options); /** * @see Zend_Ldap_Exception */ require_once 'Zend/Ldap/Exception.php'; throw new Zend_Ldap_Exception(null,"Unknown Zend_Ldap option: $key"); } $this->_optiOns= $permittedOptions; return $this; }
我该如何实现?