本文整理匯總了PHP中Ldap::bind方法的典型用法代碼示例。如果您正苦於以下問題:PHP Ldap::bind方法的具體用法?PHP Ldap::bind怎麽用?PHP Ldap::bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Ldap
的用法示例。
在下文中一共展示了Ldap::bind方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBindAnonymous
public function testBindAnonymous()
{
$ldap = new Ldap($this->container);
self::$functions->expects($this->once())->method('ldap_bind')->with($this->equalTo('my_ldap_connection'), $this->equalTo(null), $this->equalTo(null))->will($this->returnValue(true));
$this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'anonymous'));
}
示例2: Ldap
if (array_key_exists('login', $_POST)) {
$usuario = $_POST['login'];
$conn = new Ldap();
$result = $conn->search($base_dn, "uid={$_POST['login']}", array('cn', 'employeeNumber'));
$entry = $result->first();
$user_dn = $result->entry_dn();
$user_pw = $_POST['senha'];
/**
* Faz o login e incia a sessao
* Informaçoes disponiveis na sessao:
* $_SESSION['usuarioNome'] --> Nome completo do Usuario (Fonte: Ldap)
* $_SESSION['siape'] -> SIAPE do servidor (Fonte: Ldap)
* $_SESSION['usuario'] -> login do usuario (mesmo do E-mail institucional)
*
*/
if ($conn->bind($user_dn, $user_pw)) {
$_SESSION['usuarioNome'] = $entry['cn'][0];
$_SESSION['siape'] = $entry['employeeNumber'][0];
// $_SESSION['siape'] ="390111";
$_SESSION['usuario'] = $usuario;
/*$_SESSION['usuario'] = 'arfonseca';*/
header('location: /ponto/index.php');
exit;
} else {
$msg = 'Usuario ou senha inválido!';
}
}
?>
<!DOCTYPE html> <html lang="en">
<head>
<meta charset="utf-8">