当前位置: 首页>>代码示例>>PHP>>正文


PHP general::run方法代码示例

本文整理汇总了PHP中general::run方法的典型用法代码示例。如果您正苦于以下问题:PHP general::run方法的具体用法?PHP general::run怎么用?PHP general::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在general的用法示例。


在下文中一共展示了general::run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public static function run($inContent = '')
 {
     $user = currentUser::getUserSession();
     if ($user->isLoggedIn()) {
         return;
     }
     $pluginEnabled = VariableEngine::getInstance()->getVariable('ldapEnabled');
     if ($pluginEnabled === false) {
         return;
     }
     if ($pluginEnabled->getValue() === 'false') {
         return;
     }
     $variableEngine = VariableEngine::getInstance();
     $ldapServer = $variableEngine->getVariable('ldapServer');
     if ($ldapServer === false) {
         return;
     }
     $ldapDomain = $variableEngine->getVariable('ldapDomain');
     if ($ldapDomain === false) {
         return;
     }
     $ldapIsActiveDirectory = $variableEngine->getVariable('ldapIsActiveDirectory');
     if ($ldapIsActiveDirectory === false) {
         return;
     }
     $ldapConnection = ldap_connect($ldapServer->getValue());
     if (!$ldapConnection) {
         return;
     }
     ldap_set_option($ldapConnection, LDAP_OPT_REFERRALS, 0);
     ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_start_tls($ldapConnection);
     $userName = htmlspecialchars($_POST['username']);
     $password = htmlspecialchars($_POST['password']);
     if ($userName === null) {
         return;
     }
     if ($userName === '') {
         return;
     }
     if ($password === null) {
         return;
     }
     if ($password === '') {
         return;
     }
     $authenticated = ldap_bind($ldapConnection, $userName . '@' . $ldapDomain->getValue(), $password);
     unset($password);
     if (!$authenticated) {
         ldap_close($ldapConnection);
         return;
     }
     $database = database::getInstance();
     $userName = $database->escapeString($userName);
     $haveSeenBefore = $database->getData('userID', 'activeDirectory', 'WHERE adUsername=\'' . $userName . '\'');
     if ($haveSeenBefore === null) {
         $ou = $variableEngine->getVariable('ldapOrganizationUnit');
         if ($ou === false) {
             ldap_close($ldapConnection);
             return;
         }
         $dn = 'cn=' . $userName . ',ou=' . $ou->getValue();
         $domain = explode('.', $ldapDomain->getValue());
         $numberOfSubServers = count($domain);
         for ($i = 0; $i < $numberOfSubServers; $i++) {
             $dn .= ',dc=' . $domain[$i];
         }
         $search = ldap_read($ldapConnection, $dn, '(objectclass=*)', array('sn', 'givenname', 'mail'));
         if (!$search) {
             ldap_close($ldapConnection);
             return;
         }
         $info = ldap_get_entries($ldapConnection, $search);
         ldap_close($ldapConnection);
         if ($info['count'] !== 1) {
             return;
         }
         $function = new general('generateRandomString');
         $password = $function->run(array('length' => 50));
         $defaultRoleID = $variableEngine->getVariable('ldapDefaultRoleID');
         if ($defaultRoleID === false) {
             return;
         }
         $defaultRoleID = $defaultRoleID->getValue();
         //No email found in ad
         if ($info[0]['count'] === 2) {
             if ($info[0]['sn']['count'] !== 1) {
                 return;
             }
             if ($info[0]['givenname']['count'] !== 1) {
                 return;
             }
             $firstName = $info[0]['givenname'][0];
             $lastName = $info[0]['sn'][0];
             if (!self::addUser($firstName, $lastName, $userName, $password, $defaultRoleID)) {
                 return;
             }
             self::logIn($userName);
             return;
//.........这里部分代码省略.........
开发者ID:educask,项目名称:EducaskCore,代码行数:101,代码来源:authenticateWithLDAP.inc.php


注:本文中的general::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。