Skip to content

Error handling

Rich2k edited this page Apr 18, 2013 · 1 revision

When using adLDAP functions, many of the PHP fatal errors are supressed to allow continued execution of scripts and the return of false responses from a function.

getLastError()

This function allows you to return the last error message that Active Directory encountered.

$disableAccount = $adldap->user()->disable('AD.UserName');

if ($disableAccount === false) {
    echo $adldap->getLastError();
}

Exception Handling

For bind/connection errors or where SSL is required and not configured e.g. modifying passwords then adLDAP will throw an adLDAPException.

These can be handled as follows

try {
    $adldap = new adLDAP();
}
catch (adLDAPException $e) {
    echo $e; exit();
}

or

try {
    $modifyPassword = $adldap->user()->password($username, $newpassword);
    /* ... Other Code here ... */
}
catch (adLDAPException $e) {
    echo $e; exit();
}
Clone this wiki locally