Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Dorset, UK
    Posts
    4

    Smile Unanswered: 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 04:54.

  2. #2
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •