Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL LDAP QUERY

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
I was advised to post here. I did post in VBScript.

Hi,

I'm trying to search for all users in AD and return enabled accounts and accounts that are not members of a particular group.

Here is the LDAP / SQL query.
Code:
objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=int,dc=mosaichomes,dc=co,dc=uk' WHERE objectCategory='Person' AND <> userAccountControl:1.2.840.113556.1.4.803:='2' AND <> memberOf='CN=GG_NOSHOWINPHONELIST,OU=Domain Global,OU=Groups,OU=ENTIRE ORG Test,DC=mydomain,DC=co,DC=uk'"

As is, I get to records, however if I take out everything to the right of 'Person' it returns all accounts. I've tried the userAccountControl with the memberof and visa-versa. Still no luck.

If anyone can point out what is wrong, I'd be most grateful.

Many thanks

Woter.
 
Opps. The penultimate paragraph should read:

As is, I get NO records returned (sits there not doing much and not ending). If I take out everything to the right of 'Person' it returns all accounts.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top