NTDOC
|
(KiX Master)
|
2003-01-21 11:23 PM
|
|
|
|
|
GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
; *** FUNCTION: GetAllADUserInfoToFile() ; *** AUTHOR: Ron Lewis/NTDOC ; *** DATE CREATED: 2003-01-10 21:10 PST ; *** ACKNOWLEDGEMENTS: Special thanks to Lonkero for help with array parsing of names ; *** SYNTAX: GetAllADUserInfoToFile ; *** PARAMETERS: (you must supply the LDAP lookup path and file name to save) ; *** ACTION: This file queries the Active Directory for all user information ; *** and copies it to a supplied file name and location. It is designed for multiple OU query ; *** Does not include group membership and security information. The file uses a * for a ; *** delimiter to make import into Excel easier for report viewing. ; *** DEPENDENCIES: (KiXtart 4.02 or later) (Windows 2000 AD) (ADSI (2000 and XP workstations have ADSI))
; *************** REVISION HISTORY *************** ; 001.02 *** 2003-01-16 15:10 PST by Ron Lewis ; Enabled multiple OU usage ; 001.01 *** 2003-01-15 13:50 PST by Ron Lewis ; Cleared up variables ; 001.00 *** 2003-01-10 21:10 PST by Ron Lewis ; original file release
; *** USAGE EXAMPLE: BREAK On $FileName="C:\TEMP\ADUserInfo.txt" $LDAP="LDAP://ou=Users,ou=business1, your company rootDSE info", "LDAP://ou=Users,ou=business2, your company rootDSE info" GetAllADUserInfoToFile
code:
Function GetAllADUserInfoToFile() For each $domain in $LDAP $ou = GetObject($domain) For each $user in $ou $all="" $StreetValue="" $direct="" $mymanager="" $mymail="" $MyDescription="" $MyTelephoneNotes="" $MyCompany="" ; This block gathers the users Name and strips off the extra path data ; *********************************************************************** IF $user.name $name=split(substr($user.name,4),",") $name[0]=join(split($name[0],"\"),"") $name=join($name,",") ENDIF ; ***********************************************************************
; This block gathers the users smtp email address and strips off the word ; "email." after the @ sign ; *********************************************************************** IF $user.mail $mymail=split(substr($user.mail,1),",") $mymail[0]=join(split($mymail[0],"email."),"") $mymail=join($mymail,",") ENDIF ; ***********************************************************************
; This block gathers the Manager and strips off the extra path data ; *********************************************************************** IF $user.manager $mymanager=split(substr($user.manager,4),",") $mymanager=join(split($mymanager[0],"\"),"")+","+$mymanager[1] ENDIF ; ***********************************************************************
; This block gathers the directReports and strips off the extra path data ; *********************************************************************** For each $item in $user.directReports $direct=$direct+chr(10)+$item Next IF Not $direct $direct=$user.directReports+chr(10) ENDIF For each $value in split($direct,chr(10)) IF $value $value=split(substr($value,4),",") $all=$all+" "+join(split($value[0],"\"),"")+","+$value[1] $all=SUBSTR($all,2) ENDIF Next ; ***********************************************************************
$StreetValue=join(split($user.streetAddress,@CRLF)," ") $MyDescription=join(split($user.description,@CRLF,),"") $MyTelephoneNotes=join(split($user.info,@CRLF,),"") $MyCompany=join(split($user.company,@CRLF,),"")
IF OPEN(1,"$FileName", 5)= 0 $out = WriteLine(1, $user.givenName+"*"+$user.initials+"*"+$user.sn+"*"+$user.displayname+"*"+ $MyDescription+"*"+$user.physicalDeliveryOfficeName+"*"+$user.telephoneNumber+"*"+$mymail+"*"+ $user.wWWHomePage+"*"+$user.url+"*"+$StreetValue+"*"+$user.postOfficeBox+"*"+$user.l+"*"+ $user.st+"*"+$user.postalCode+"*"+$user.c+"*"+$user.sAMAccountName+"*"+$user.userPrincipalName+ "*"+$user.userWorkstations+"*"+$user.profilePath+"*"+$user.scriptPath+"*"+$user.homeDrive+"*"+ $user.homeDirectory+"*"+$user.homePhone+"*"+$user.pager+"*"+$user.mobile+"*"+ $user.facsimileTelephoneNumber+"*"+$user.ipPhone+"*"+$user.otherTelephone+"*"+$MyTelephoneNotes+ "*"+$user.title+"*"+$user.department+"*"+$user.company+"*"+$mymanager+"*"+$all+"*"+@crlf) $x = CLOSE(1) ENDIF
Next Next EndFunction
[ 22. January 2003, 21:28: Message edited by: NTDOC ]
|
Chris S.
|
(MM club member)
|
2003-01-22 03:03 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
Nice, Ron.
Is it possible to break up the long line?
|
Jochen
|
(KiX Supporter)
|
2003-01-22 03:09 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
Freeze ! Long Line Police !!!
Hand over all your donuts
Think of adding a wordwrap option to PostPrep ... Jooel ?
|
Les
|
(KiX Master)
|
2003-01-22 04:11 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
Tsk, Tsk... Of all people, a moderator posting perhaps the longest line in the history of korg!
|
NTDOC
|
(KiX Master)
|
2003-01-22 09:30 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
Hey... but its a good line.
I don't mod this forum though! LOL
All better now... call off the Long Line Police Dogs
|
Lonkero
|
(KiX Master Guru)
|
2003-01-22 09:35 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
please, no line cuts in UDFs...
|
Radimus
|
(KiX Supporter)
|
2003-01-22 11:23 PM
|
|
|
|
|
Re: GetAllADUserInfoToFile() Queries the AD for all user information and writes to file
|
|
moved here so all you old ladies can chatter about the long lines...
|