for the most part when I query a user using the following function:
function passwordExpires($userDN) {
$comLDAP = new COM('LDAP:');
$getUser = $comLDAP->OpenDSObject('LDAP://' . $this->server . '/' .
$userDN, $this->domain . "\\" . $this->user, $this->pass, 1);
$dateParse = date_parse($getUser->passwordLastChanged);
$today = time();
$expDate = mktime($dateParse[hour],$dateParse[minute],
$dateParse[second],$dateParse[month],$dateParse[day]
+45,$dateParse[year]);
$days = floor(($expDate-$today)/(60*60*24));
$hours = floor(((($expDate-$today)/(60*60*24))- $days)*24);
$dayText = ($days != 1) ? " Days " : " Day ";
$hrsText = ($hours != 1) ? " Hours " : " Hour ";
return ($days.$dayText.$hours.$hrsText);
}
This script works fine querying most distinguishedName values. Where
I keep running into a problem is with a specific OU that has braces
'( )' in the name. This has also occurred when the CN has a braces in
it. (eg "CN=Joe Smith (Department),OU=...")
I receive the following error in my php.log file:
PHP Fatal error: Uncaught exception 'com_exception' with message
'<b>Source:</bUnknown<br/><b>Description:</bUnknown' in C:
\development\class.easyADSI.php:190
Stack trace:
#0 C:\development\class.easyADSI.php(190): com->OpenDSObject('LDAP://
server....', 'DOMAIN\admin', 'password', 1)
#1 C:\development\class.easyADSI.php(271): EasyADSI-
>passwordExpires('CN=First Last...')#2 {main}
thrown in C:\development\class.easyADSI.php on line 190
I know that the script is dying on:
$getUser = $comLDAP->OpenDSObject('LDAP://' . $this->server . '/' .
$userDN, $this->domain . "\\" . $this->user, $this->pass, 1);
I know that the LDAP functions in PHP may be able to help but the
server does not have the LDAP function turned on in PHP so I must use
ADSI.
MSDN has helped out a little bit in explaining that I may need to
escape these characters (http://msdn.microsoft.com/en-us/library/
aa366101(VS.85).aspx) but when I have tried the suggestions it still
errors out.
Can anyone give me a hand with this?