473,769 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($get User->passwordLastCh anged);
$today = time();
$expDate = mktime($datePar se[hour],$dateParse[minute],
$dateParse[second],$dateParse[month],$dateParse[day]
+45,$dateParse[year]);
$days = floor(($expDate-$today)/(60*60*24));
$hours = floor(((($expDa te-$today)/(60*60*24))- $days)*24);
$dayText = ($days != 1) ? " Days " : " Day ";
$hrsText = ($hours != 1) ? " Hours " : " Hour ";
return ($days.$dayText .$hours.$hrsTex t);
}

This script works fine querying most distinguishedNa me 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\cl ass.easyADSI.ph p: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-
>passwordExpire s('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 3158
zm****@gmail.co m 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($get User->passwordLastCh anged);
$today = time();
$expDate = mktime($datePar se[hour],$dateParse[minute],
$dateParse[second],$dateParse[month],$dateParse[day]
+45,$dateParse[year]);
$days = floor(($expDate-$today)/(60*60*24));
$hours = floor(((($expDa te-$today)/(60*60*24))- $days)*24);
$dayText = ($days != 1) ? " Days " : " Day ";
$hrsText = ($hours != 1) ? " Hours " : " Hour ";
return ($days.$dayText .$hours.$hrsTex t);
}

This script works fine querying most distinguishedNa me 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\cl ass.easyADSI.ph p: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-
>passwordExpire s('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*******@attgl obal.net
=============== ===

Jun 2 '08 #2

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

Similar topics

4
7375
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 20-30 different domains) with 25K+ users. i dont want to use "NT challenge response" for this pupose. I am exploring ways using ADSI and WMI to query the Active directory by using the IP address in the incoming web request and trying to figure...
5
5137
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 However if I update any other column the syntax is fine
7
1752
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 the code, any clues?? Thanks. <code> #include <stdio.h> #include <stdlib.h> enum states { FREE, INQUOTE, INCOMMENT, SLASH, ASTERISK, SCAPE };
102
5715
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 can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
10
9887
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
1155
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 explicit pagesize statement, and the findall.count value went up from 1000 to 4000+ for the OU that I'm querying. (with considerable added delay in response). However when I try to iterate through a for-each loop, I still seem to get only 1000 items. ...
6
4087
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, having been advised by several luminaries that that is a "good thing to do"... :-) However, I'm experiencing a problem with the IEnumerable interface. (N.B. I understand fully that I should be using the LDAP provider instead of the WinNT provider...
19
2634
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string? ----------------------------------------------------------------------- There are two equivalent ways to access properties: the dot notation and the square bracket notation. What you are looking for is the square bracket notation in which the dot, and the identifier to its right, are replaced with a...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.