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


PHP adLDAP::authenticate方法代码示例

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


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

示例1: checkLdapCredentials

 public static function checkLdapCredentials($username, $password)
 {
     $options = sfConfig::get('app_sf_guard_plugin_ldap_settings', array());
     $ldap = new adLDAP($options);
     $authenticated = $ldap->authenticate($username, $password);
     return $authenticated ? true : false;
 }
开发者ID:Alenpiera,项目名称:streeme,代码行数:7,代码来源:StreemeLdapUser.class.php

示例2: executeSignin

 public function executeSignin($request)
 {
     $this->form = new sfGuardFormSignin();
     if ($request->isMethod('post')) {
         $data = $request->getParameter('signin');
         $adldap = new adLDAP(array('account_suffix' => '@sch.bme.hu', 'domain_controllers' => array('152.66.208.42'), 'ad_username' => $data['username'], 'ad_password' => $data['password']));
         try {
             $authUser = $adldap->authenticate($data['username'], $data['password']);
             if ($authUser === true) {
                 $userData = $adldap->user_info($data['username']);
                 $user = Doctrine::getTable('sfGuardUser')->findOneBy('username', $data['username']);
                 $save = false;
                 if ($user) {
                     if ($user->Profile->full_name != $userData[0]["displayname"][0] || $user->Profile->email != $userData[0]["mail"][0]) {
                         $save = true;
                     }
                 } else {
                     $user = new sfGuardUser();
                     $save = true;
                 }
                 if ($save) {
                     $user->username = $data['username'];
                     $user->password = $data['password'];
                     $user->Profile->full_name = $userData[0]["displayname"][0];
                     $user->Profile->email = $userData[0]["mail"][0];
                     $user->save();
                 }
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
     parent::executeSignin($request);
 }
开发者ID:szelpe,项目名称:cukorka,代码行数:34,代码来源:actions.class.php

示例3: authAD

 public function authAD()
 {
     $adldap = new adLDAP();
     if ($adldap->authenticate($this->login, $this->password)) {
         $user_info = $adldap->user()->info($this->login);
         $this->display_name = $user_info[0]['displayname'][0];
         $this->logged = true;
         $this->is_admin = $this->isAdmin($user_info);
     } else {
         $this->logged = false;
     }
 }
开发者ID:fire-coding,项目名称:gis,代码行数:12,代码来源:user.php

示例4: loginUser

 function loginUser()
 {
     $ldapOptions = array('account_suffix' => '@solitude.guc.usg.edu', 'base_dn' => 'ou=GGCNet,dc=solitude,dc=guc,dc=usg,dc=edu', 'domain_controllers' => array('llyr.solitude.guc.usg.edu'));
     $ldapOptions = array('account_suffix' => '@ggc.edu', 'base_dn' => 'ou=GGCNet,dc=ggc,dc=edu', 'domain_controllers' => array('ldap.ggc.edu'));
     $ldap = new adLDAP($ldapOptions);
     if ($ldap->authenticate($_POST['login_user'], self::decryptRSA($_POST['login_pass']))) {
         $_SESSION['loggedInParking'] = strtolower($_POST['login_user']);
         // allow commenting
         $_SESSION['allowComments'] = true;
     } else {
         //print_r($_POST);
         //die("Invalid password / username combination.");
         header("location: index.php?error=1");
         die;
     }
 }
开发者ID:bwood1,项目名称:InternetSecurityProject,代码行数:16,代码来源:login_class.php

示例5: selectUserFromLdap

 function selectUserFromLdap($username, $password)
 {
     try {
         $adldap = new adLDAP();
         $adldap->set_account_suffix('@vejleidraetsefterskole.local');
         $adldap->set_domain_controllers(array('mail.vih.dk'));
     } catch (adLDAPException $e) {
         echo $e;
         exit;
     }
     $authUser = $adldap->authenticate($username, $password);
     if ($authUser === true) {
         return new k_AuthenticatedUser($username);
     } else {
         throw new Exception('User authentication unsuccessful. ' . $adldap->get_last_error());
     }
 }
开发者ID:vih,项目名称:intranet.vih.dk,代码行数:17,代码来源:Login.php

示例6: getCredentials

 /**
  *
  * @param string $username
  * @param string $password
  * @param string $method
  * @return Users 
  */
 public function getCredentials($username, $password, $method = 'internal')
 {
     if ($method == "ldap") {
         require_once ROOT_PATH . 'lib/common/ldap/adLDAP.php';
         $ldap = new adLDAP();
         // Authenticate using adLDAP configuratoin
         $authLdap = $ldap->authenticate($username, $password);
         if ($authLdap) {
             // Get the internally created user account (ESS/Admin accounts listed under users)
             $query = Doctrine_Query::create()->from('SystemUser')->where('user_name = ?', $username)->andWhere('deleted = 0');
         } else {
             // Return an empty result set if authentication is false
             $query = Doctrine_Query::create()->from('SystemUser')->where('1 = 2');
         }
     } else {
         $query = Doctrine_Query::create()->from('SystemUser')->where('user_name = ?', $username)->andWhere('user_password = ?', $password)->andWhere('deleted = 0');
     }
     return $query->fetchOne();
 }
开发者ID:pard4l,项目名称:orangehrm-ldap,代码行数:26,代码来源:AuthenticationDao.php

示例7: login

 function login($username, $password)
 {
     if ($password == 'vih') {
         $this->logged_in = true;
         return true;
     }
     if ($username != NULL && $password != NULL) {
         //include the class and create a connection
         require_once dirname(__FILE__) . '/adLdap.php';
         try {
             $adldap = new adLDAP();
         } catch (adLDAPException $e) {
             echo $e;
             exit;
         }
         //authenticate the user
         if ($adldap->authenticate($username, $password)) {
             $this->logged_in = true;
             return true;
         }
     }
     return false;
 }
开发者ID:vih,项目名称:intranet.vih.dk,代码行数:23,代码来源:User.php

示例8: doLogin

 /**
  * Checks the config.php AUTHCFG value for login type and forks off to the proper module
  *
  * @param string $user_password - The password of the user to authenticate
  * @return true if the user is authenticated, false otherwise
  */
 function doLogin($user_password)
 {
     global $AUTHCFG;
     $usr_name = $this->column_fields["user_name"];
     switch (strtoupper($AUTHCFG['authType'])) {
         case 'LDAP':
             $this->log->debug("Using LDAP authentication");
             require_once 'modules/Users/authTypes/LDAP.php';
             $result = ldapAuthenticate($this->column_fields["user_name"], $user_password);
             if ($result == NULL) {
                 return false;
             } else {
                 return true;
             }
             break;
         case 'AD':
             $this->log->debug("Using Active Directory authentication");
             require_once 'modules/Users/authTypes/adLDAP.php';
             $adldap = new adLDAP();
             if ($adldap->authenticate($this->column_fields["user_name"], $user_password)) {
                 return true;
             } else {
                 return false;
             }
             break;
         default:
             $this->log->debug("Using integrated/SQL authentication");
             $encrypted_password = $this->encrypt_password($user_password);
             $query = "SELECT id from {$this->table_name} where deleted=0 and user_name='{$usr_name}' AND user_password='{$encrypted_password}'";
             $result = $this->db->query($query);
             $noofrows = $this->db->num_rows($result);
             if ($noofrows > 0) {
                 $id = $this->db->query_result($result, 0, "id");
                 $this->log->debug("Using integrated/SQL authentication id:" . $id);
                 return true;
             } else {
                 $this->log->debug("Using integrated/SQL authentication NO Record");
                 return false;
             }
             break;
     }
     return false;
 }
开发者ID:honj51,项目名称:taobaocrm,代码行数:49,代码来源:Users.php

示例9: login

 function login($return = '')
 {
     if (func_get_args()) {
         $return_parts = func_get_args();
         $return = implode('/', $return_parts);
     }
     if ($this->authorized()) {
         redirect($return);
     }
     $check = FALSE;
     // If no valid mechanisms found, bail
     if (!$this->auth_mechanisms) {
         redirect('auth/generate');
     }
     $login = isset($_POST['login']) ? $_POST['login'] : '';
     $password = isset($_POST['password']) ? $_POST['password'] : '';
     // User is a member of these groups
     $groups = array();
     // Loop through authentication mechanisms
     // Break when we have a match
     foreach ($this->auth_mechanisms as $mechanism => $auth_data) {
         // Local is just a username => hash array
         switch ($mechanism) {
             case 'noauth':
                 // No authentication
                 $check = TRUE;
                 $login = 'admin';
                 break 2;
             case 'config':
                 // Config authentication
                 if ($login && $password) {
                     if (isset($auth_data[$login])) {
                         $t_hasher = $this->load_phpass();
                         $check = $t_hasher->CheckPassword($password, $auth_data[$login]);
                         if ($check) {
                             // Get group memberships
                             foreach (conf('groups', array()) as $groupname => $members) {
                                 if (in_array($login, $members)) {
                                     $groups[] = $groupname;
                                 }
                             }
                         }
                         break 2;
                     }
                 }
                 break;
             case 'ldap':
                 // LDAP authentication
                 if ($login && $password) {
                     include_once APP_PATH . '/lib/authLDAP/authLDAP.php';
                     $ldap_auth_obj = new Auth_ldap($auth_data);
                     if ($ldap_auth_obj->authenticate($login, $password)) {
                         //alert('Authenticated');
                         // Check user against users list
                         if (isset($auth_data['mr_allowed_users'])) {
                             $admin_users = is_array($auth_data['mr_allowed_users']) ? $auth_data['mr_allowed_users'] : array($auth_data['mr_allowed_users']);
                             if (in_array(strtolower($login), array_map('strtolower', $admin_users))) {
                                 $check = TRUE;
                                 // If business units enabled, get group memberships
                                 if (conf('enable_business_units')) {
                                     if ($user_data = $ldap_auth_obj->getUserData($login)) {
                                         $groups = $user_data['grps'];
                                     }
                                 }
                                 break 2;
                             }
                         }
                         // Check user against group list
                         if (isset($auth_data['mr_allowed_groups'])) {
                             // Set mr_allowed_groups to array
                             $admin_groups = is_array($auth_data['mr_allowed_groups']) ? $auth_data['mr_allowed_groups'] : array($auth_data['mr_allowed_groups']);
                             // Get groups from AD
                             if ($user_data = $ldap_auth_obj->getUserData($login)) {
                                 foreach ($user_data['grps'] as $group) {
                                     if (in_array($group, $admin_groups)) {
                                         $check = TRUE;
                                         // If business units enabled, store group memberships
                                         if (conf('enable_business_units')) {
                                             $groups = $user_data['grps'];
                                         }
                                         break 3;
                                     }
                                 }
                             }
                         }
                         //end group list check
                         // Not in users list or group list
                         error('Not authorized', 'auth.not_authorized');
                         break;
                     }
                 }
             case 'AD':
                 // Active Directory authentication
                 // Prevent empty values
                 if ($_POST && $login && $password) {
                     //include the class and create a connection
                     //TODO: wrap this include somewhere else?
                     include_once APP_PATH . '/lib/adLDAP/adLDAP.php';
                     try {
                         $adldap = new adLDAP($auth_data);
//.........这里部分代码省略.........
开发者ID:pexner,项目名称:munkireport-php,代码行数:101,代码来源:auth.php

示例10: login

 function login($return = '')
 {
     if ($this->authorized()) {
         redirect($return);
     }
     $check = FALSE;
     // If no valid mechanisms found, bail
     if (!$this->auth_mechanisms) {
         redirect('auth/generate');
     }
     $login = isset($_POST['login']) ? $_POST['login'] : '';
     $password = isset($_POST['password']) ? $_POST['password'] : '';
     // Loop through authentication mechanisms
     // Break when we have a match
     foreach ($this->auth_mechanisms as $mechanism => $auth_data) {
         // Local is just a username => hash array
         switch ($mechanism) {
             case 'noauth':
                 // No authentication
                 $check = TRUE;
                 $login = 'noauth';
                 break 2;
             case 'config':
                 // Config authentication
                 if ($_POST && isset($auth_data[$login])) {
                     $t_hasher = $this->load_phpass();
                     $check = $t_hasher->CheckPassword($password, $auth_data[$login]);
                     break 2;
                 }
                 break;
             case 'ldap':
                 // LDAP authentication
                 if ($login && $password) {
                     include_once APP_PATH . '/lib/authLDAP/authLDAP.php';
                     $ldap_auth_obj = new Auth_ldap($auth_data);
                     if ($ldap_auth_obj->authenticate($login, $password)) {
                         //alert('Authenticated');
                         // Check user against users list
                         if (isset($auth_data['mr_allowed_users'])) {
                             //
                             $admin_users = is_array($auth_data['mr_allowed_users']) ? $auth_data['mr_allowed_users'] : array($auth_data['mr_allowed_users']);
                             if (in_array(strtolower($login), array_map('strtolower', $admin_users))) {
                                 $check = TRUE;
                                 break 2;
                             }
                         }
                         // Check user against group list
                         if (isset($auth_data['mr_allowed_groups'])) {
                             // Set mr_allowed_groups to array
                             $admin_groups = is_array($auth_data['mr_allowed_groups']) ? $auth_data['mr_allowed_groups'] : array($auth_data['mr_allowed_groups']);
                             // Get groups from AD
                             if ($user_data = $ldap_auth_obj->getUserData($login)) {
                                 foreach ($user_data['grps'] as $group) {
                                     if (in_array($group, $admin_groups)) {
                                         $check = TRUE;
                                         break 3;
                                     }
                                 }
                             }
                         }
                         //end group list check
                         // Not in users list or group list
                         error(lang('not_authorized'));
                         break;
                     }
                 }
             case 'AD':
                 // Active Directory authentication
                 // Prevent empty values
                 if ($_POST && $login && $password) {
                     //include the class and create a connection
                     //TODO wrap this include somewhere else?
                     include_once APP_PATH . '/lib/adLDAP/adLDAP.php';
                     try {
                         $adldap = new adLDAP($auth_data);
                     } catch (adLDAPException $e) {
                         // When in debug mode, show additional info
                         $msg = conf('debug') ? ":<br>" . $e->getMessage() : '';
                         error(lang('error_contacting_AD') . $msg);
                         break 2;
                     }
                     // Authenticate user
                     if ($adldap->authenticate($login, $password)) {
                         // Check user against userlist
                         if (isset($auth_data['mr_allowed_users'])) {
                             //
                             $admin_users = is_array($auth_data['mr_allowed_users']) ? $auth_data['mr_allowed_users'] : array($auth_data['mr_allowed_users']);
                             if (in_array(strtolower($login), array_map('strtolower', $admin_users))) {
                                 $check = TRUE;
                                 break 2;
                             }
                         }
                         // Check user against group list
                         if (isset($auth_data['mr_allowed_groups'])) {
                             // Set mr_allowed_groups to array
                             $admin_groups = is_array($auth_data['mr_allowed_groups']) ? $auth_data['mr_allowed_groups'] : array($auth_data['mr_allowed_groups']);
                             // Get groups from AD
                             $groups = $adldap->user()->groups($login);
                             foreach ($groups as $group) {
                                 if (in_array($group, $admin_groups)) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:munkireport,代码行数:101,代码来源:auth.php

示例11: doLogin

 /**
  * Checks the config.php AUTHCFG value for login type and forks off to the proper module
  *
  * @param string $user_password - The password of the user to authenticate
  * @return true if the user is authenticated, false otherwise
  */
 function doLogin($user_password)
 {
     global $AUTHCFG;
     $usr_name = $this->column_fields["user_name"];
     switch (strtoupper($AUTHCFG['authType'])) {
         case 'LDAP':
             $this->log->debug("Using LDAP authentication");
             require_once 'modules/Users/authTypes/LDAP.php';
             $result = ldapAuthenticate($this->column_fields["user_name"], $user_password);
             if ($result == NULL) {
                 return false;
             } else {
                 return true;
             }
             break;
         case 'AD':
             $this->log->debug("Using Active Directory authentication");
             require_once 'modules/Users/authTypes/adLDAP.php';
             $adldap = new adLDAP();
             if ($adldap->authenticate($this->column_fields["user_name"], $user_password)) {
                 return true;
             } else {
                 return false;
             }
             break;
         default:
             $this->log->debug("Using integrated/SQL authentication");
             $query = "SELECT crypt_type FROM {$this->table_name} WHERE user_name=?";
             $result = $this->db->requirePsSingleResult($query, array($usr_name), false);
             if (empty($result)) {
                 return false;
             }
             $crypt_type = $this->db->query_result($result, 0, 'crypt_type');
             $encrypted_password = $this->encrypt_password($user_password, $crypt_type);
             $maxFailedLoginAttempts = GlobalVariable::getVariable('Application_MaxFailedLoginAttempts', 5);
             $query = "SELECT * from {$this->table_name} where user_name=? AND user_password=?";
             $params = array($usr_name, $encrypted_password);
             $cnuser = $this->db->getColumnNames($this->table_name);
             if (in_array('failed_login_attempts', $cnuser)) {
                 $query .= ' AND COALESCE(failed_login_attempts,0)<?';
                 $params[] = $maxFailedLoginAttempts;
             }
             $result = $this->db->requirePsSingleResult($query, $params, false);
             if (empty($result)) {
                 return false;
             } else {
                 return true;
             }
             break;
     }
     return false;
 }
开发者ID:kduqi,项目名称:corebos,代码行数:58,代码来源:Users.php

示例12: dirname

<?php

/*$ldap['user']              = 'lalmendras'; //'sanvtbouser';
$ldap['pass']              = 'Informacion089'; //'Datawarehous3';  
$ldap['host']              = '10.40.3.97'; // nombre del host o servidor  
$ldap['port']              = 389; // puerto del LDAP en el servidor  
$ldap['dn']                = 'uid='.$ldap['user'].',OU=GEOI,OU=VP-IT,OU=CB,OU=NUEVATEL,OU=Servicios,OU=Usuarios,DC=nuevatel,DC=net'; // modificar respecto a los valores del LDAP  
$ldap['base']              = 'DC=nuevatel,DC=net';  
*/
require_once dirname(__FILE__) . '/adLDAP.php';
$options["domain_controllers"] = array("10.40.3.97", "10.20.3.97", "10.30.3.97");
$user = 'lalmendras';
$password = 'Informacion0';
$options["ad_username"] = $user;
//el usuario de active directory
$options["ad_password"] = $password;
$options["use_ssl"] = false;
$ldap = new adLDAP();
$aut = $ldap->authenticate($user, $password);
if ($aut) {
    echo 'ok';
} else {
    echo 'error';
}
开发者ID:vicholuis,项目名称:proyectopruebalms,代码行数:24,代码来源:test_ldap.php

示例13: doLogin

    /**
     * Checks the config.php AUTHCFG value for login type and forks off to the proper module
     *
     * @param string $user_password - The password of the user to authenticate
     * @return true if the user is authenticated, false otherwise
     */
    function doLogin($user_password) {
        global $AUTHCFG;
        $usr_name = $this->column_fields["user_name"];

        switch (strtoupper($AUTHCFG['authType'])) {
            case 'LDAP':
                $this->log->debug("Using LDAP authentication");
                require_once('modules/Users/authTypes/LDAP.php');
                $result = ldapAuthenticate($this->column_fields["user_name"], $user_password);
                if ($result == NULL) {
                    return false;
                } else {
                    return true;
                }
                break;

            case 'AD':
                $this->log->debug("Using Active Directory authentication");
                require_once('modules/Users/authTypes/adLDAP.php');
                $adldap = new adLDAP();
                if ($adldap->authenticate($this->column_fields["user_name"],$user_password)) {
                    return true;
                } else {
                    return false;
                }
                break;

            default:
                $this->log->debug("Using integrated/SQL authentication");
                $query = "SELECT crypt_type, user_name FROM $this->table_name WHERE user_name=?";
                $result = $this->db->requirePsSingleResult($query, array($usr_name), false);
                if (empty($result)) {
                    return false;
                }
                $crypt_type = $this->db->query_result($result, 0, 'crypt_type');
				$this->column_fields["user_name"] = $this->db->query_result($result, 0, 'user_name');
                $encrypted_password = $this->encrypt_password($user_password, $crypt_type);
                $query = "SELECT 1 from $this->table_name where user_name=? AND user_password=? AND status = ?";
                $result = $this->db->requirePsSingleResult($query, array($usr_name, $encrypted_password, 'Active'), false);
                if (empty($result)) {
                    return false;
                } else {
                    return true;
                }
                break;
        }
        return false;
    }
开发者ID:Wasage,项目名称:werpa,代码行数:54,代码来源:Users.php

示例14: adLDAP

<?php

/*
Examples file

To test any of the functions, just change the 0 to a 1.
*/
//error_reporting(E_ALL ^ E_NOTICE);
include "adLDAP.php";
$ldap = new adLDAP($options);
//var_dump($ldap);
echo "<pre>\n";
// authenticate a username/password
if (0) {
    $result = $ldap->authenticate("username", "password");
    var_dump($result);
}
// add a group to a group
if (0) {
    $result = $ldap->group_add_group("Parent Group Name", "Child Group Name");
    var_dump($result);
}
// add a user to a group
if (0) {
    $result = $ldap->group_add_user("Group Name", "username");
    var_dump($result);
}
// create a group
if (0) {
    $attributes = array("group_name" => "Test Group", "description" => "Just Testing", "container" => array("Groups", "A Container"));
    $result = $ldap->group_create($attributes);
开发者ID:hcvcastro,项目名称:pxp,代码行数:31,代码来源:examples.php

示例15: dirname

<?php

require_once dirname(__FILE__) . '/adLDAP.php';
$adldap = new adLDAP(array("account_suffix" => "@test.slimcrm.com", "base_dn" => "DC=test,DC=slimcrm,DC=com", "domain_controllers" => array("50.57.184.4"), "admin_username" => "administrator", "admin_password" => "CTL-tmp-domaintestD5v5mqV6D"));
echo $adldap->authenticate("tholum", "Password1");
echo "\n";
$c = $adldap->user()->groups('tholum');
var_dump($c);
开发者ID:name256,项目名称:crm42,代码行数:8,代码来源:test.php


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