If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Help with a script search of Active Directory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-04, 03:37
jmb2000 jmb2000 is offline
Registered User
 
Join Date: Feb 2004
Location: Dorset, UK
Posts: 4
Smile Help with a script search of Active Directory

Hi guys, just a quick question hopefully someone can help me with. I have a script using an LDAP search to find various user accounts in AD and output them to a text file which works fine, however I would like to exclude a certain OU from the search, I was wondering if there was a While Not command or something similar I could use that would just fit in with the rest of the script so anyone within a specified OU is not output to the text file. Here is the output part of the script to show you the info I am looking for and where I was thinking I could put in an exclusion statement of some kind:-

If intCount = 1 Then
Set objUser = GetObject(strAdsPath)
While Not (***********)
objTextFile.WriteLine ("sAMAccountName: " & objUser.Get("sAMAccountName"))
objTextFile.WriteLine ("The Given Name is: " & objQueryResultSet.Fields("givenName"))
objTextFile.WriteLine ("The Surname is: " & objQueryResultSet.Fields("sn"))
objTextFile.WriteLine ("The AdsPath is: " & objQueryResultSet.Fields("AdsPath"))
objTextFile.WriteLine ("Description: " & objUser.Get("Description"))
objTextFile.WriteLine ("E-Mail: " & objUser.Get("mail"))
objTextFile.WriteLine Now
objTextFile.WriteBlankLines(1)
Set objUser = Nothing
End If

Any ideas would be greatfully received, thanks all

John

PS other option I could think of was putting another variable in and doing a seperate LDAP search for whether the person is in this OU and if they are switch value to true so I can use that variable in a while not statement? If this make sense?

Last edited by jmb2000; 02-10-04 at 03:54.
Reply With Quote
  #2 (permalink)  
Old 02-10-04, 06:45
jmb2000 jmb2000 is offline
Registered User
 
Join Date: Feb 2004
Location: Dorset, UK
Posts: 4
It's Ok I figured it out, put in seperate LDAP search for names in target OU, set a variable to change from false to true if they were present then put another if command just before the writeLine commands so it only outputs if they are not in target OU. I think I'm getting the hang of this scripting lark (slowly)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On