Hey Oliver...
 
If you can't figure it out through Robbie you might want to check out username which is on my web site in the free win32 tools page....
 
It will do something like this
 
F:\Dev\cpp\UserName>username -format 1
 
UserName V01.00.00cpp Joe Richards ([EMAIL PROTECTED]) October 2002
 
CN=$jricha34,CN=Users,DC=joehome,DC=com
 
F:\Dev\cpp\UserName>
 
It can pull the info in various ways and you could scrape the output or send to a file in order to use it in your script. I do most everything in perl so I write my command line tools along that vein.
 
 
  joe
 
 
F:\Dev\cpp\UserName>username /?
 
UserName V01.00.00cpp Joe Richards ([EMAIL PROTECTED]) October 2002
 
Usage:
 UserName [switches]
 

  Switches: (designated by - or /)
   -t text    Text to write in front of value (not valid with -f).
   -f file    Writes a file with cmd/bat file format with major formats.
      Variables possibly defined
       UN-DN           Fully Qualified DN
       UN-SAM          SAM Name
       UN-Display      Display Name
       UN-UniqueID     Unique ID
       UN-Canonical    Canonical Name
       UN-UPN          User Principal Name
   -format x  Format to write value in:
       1               Fully Qualified DN
       2               SAM Name
       3               Display Name
       6               Unique ID
       7               Canonical Name
       8               User Principal Name
       9               Canonical Name Extended (2 line output)
       10              Service Principal Name
 
  Note:
    Write the output to a cmd or bat file and then CALL the file and it
    will load the environment variables into the environment namespace.
 
  Ex1:
    username
      Displays current user's SAM Account Name
 
  Ex2:
    username -format 1
      Displays current user's Full Qualified DN
  Ex3:
    username -format 1 -t "set u="
      Displays current user's FQ DN as set u=<fqdn>
  Ex4:
    username -f vars.cmd
      Dumps all values it can to vars.cmd in set xxx= format
 

 This software is Freeware. Use it as you wish at your own risk.
 If you have improvement ideas, bugs, or just wish to say Hi, I
 receive email 24x7 and read it in a semi-regular timeframe.
 You can usually find me at [EMAIL PROTECTED]
 
 
--
www.joeware.net
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Oliver Marshall
Sent: Friday, December 05, 2003 10:49 AM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] [Slightly OT] OU of a user in AD

Does anyone know if the OU of a user can be retrieved via a script ?

I am using the following to TRY and set the description of the user to its OU (dont ask). but I cant find an OU parameter or similar that i can query.

For Each objUser in objDomain

    objUser.description=objuser.ou

    objUser.SetInfo

next

Reply via email to