예제 #1
0
파일: ldap.php 프로젝트: extend/wee
}
try {
    $oEntry = $oAuth->authenticateHash(array('identifier' => 'unexistant', 'password' => 'idem'));
    $this->fail('Should throw an LDAPException, credentials are incorrect.');
} catch (LDAPException $e) {
}
try {
    $oEntry = $oAuth->authenticateHash(array('identifier' => '', 'password' => ''));
    $this->fail('Should throw an LDAPException, credentials are incorrect.');
} catch (LDAPException $e) {
}
try {
    $oEntry = $oAuth->authenticateHash(array('identifier' => 'Luke Skywalker', 'password' => $oAuth->hash('bad password')));
    $this->fail('Should throw an AuthenticationException, the password value is incorrect.');
} catch (AuthenticationException $e) {
}
try {
    $oEntry = $oAuth->authenticate(array('identifier' => 'Luke Skywalker', 'password' => 'Luke Skywalker'));
    $this->isTrue(empty($oEntry['userPassword']), _WT('The password has not been removed from the entry.'));
    $oEntry = $oAuth->authenticateHash(array('identifier' => 'Luke Skywalker', 'password' => $oAuth->hash('Luke Skywalker')));
    $this->isTrue(empty($oEntry['userPassword']), _WT('The password has not been removed from the entry.'));
} catch (AuthenticationException $e) {
    $this->fail('Should not throw an AuthenticationException.');
}
try {
    $o = new weeLDAP(array('host' => '127.0.0.1', 'port' => 389, 'rdn' => 'cn=Luke Skywalker,ou=customers,dc=example,dc=com', 'password' => 'Luke Skywalker'));
    $oAuth = new weeAuthLDAP(array('ldap' => $o, 'base_dn' => 'dc=example, dc=com', 'host' => '127.0.0.1'));
    $oEntry = $oAuth->authenticateHash(array('identifier' => 'Anakin Skywalker', 'password' => $oAuth->hash('Anakin Skywalker')));
    $this->fail('Should throw an UnexpectedValueException, because user Luke Skywalker is not allowed to get admin password.');
} catch (UnexpectedValueException $e) {
}
예제 #2
0
파일: auth-ldap.php 프로젝트: extend/wee
<?php

// This could be data sent by a form, for example
$aTest = array('identifier' => 'Luke Skywalker', 'password' => 'mypassword42');
// Create the authentication driver
$oAuth = new weeAuthLDAP(array('ldap' => $oLDAP, 'base_dn' => 'ou=people, dc=example, dc=com'));
try {
    $oEntry = $oAuth->authenticate($aTest);
    // Authentication succeeded
} catch (AuthenticationException $e) {
    // Authentication failed
}