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?