473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using COM & ADSI - Bracket Problem

I am working on a script using ADSI via COM in PHP. The script works
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?
Jun 2 '08 #1
1 3129
zm****@gmail.com wrote:
I am working on a script using ADSI via COM in PHP. The script works
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?
Answered in alt.php. If you must post to multiple newsgroups, please
crosspost - don't multipost. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Akhlaq Khan | last post by:
we are developing an intranet application (web based) which needs to detect the logged in user ID of the user hitting the website. the intranet is huge and based on win2k active directory (around...
5
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value ...
7
by: El kroty | last post by:
Hi folks!! i'm trying to write k&r ex1-24 without a stack. I almost have it but there's a bug that makes me crazy and can't find it :'( whit some files it works and with others it doesn't. Here is...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
0
by: rias | last post by:
I'm new to VB.NET and ADSI. By default it appears the adsi limits objects returned to 1000 items. I've seen web references that say that the limit is imposed by unpaged queries. I added an...
6
by: Mark Rae | last post by:
Hi, I'm in the process of updating an ASP.NET v1.1 web app to v2. The app uses ActiveDirectory a great deal, and I'm trying to use the new System.Collections.Generic namespace where possible,...
19
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.