#152936 - 2005-12-06 01:21 PM
Re: Extracting Info From Active Directory
|
MACE
Starting to like KiXtart
Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
|
Looks promising but very labourious; all to retrieve an email and telephone number...
Thanks
|
|
Top
|
|
|
|
#152938 - 2005-12-09 11:29 AM
Re: Extracting Info From Active Directory
|
MACE
Starting to like KiXtart
Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
|
I am REALLY finding it dificult identifing the AD objects containing the relevant info. Even before I can search for anything ? This is where I am at and need help both filling in the gaps and formulating a search qery.
GENERAL TAB: First Name = #4 ? Initials = Last Name = #7 ? Display Name = @FullName or #10 Description = @Comment or #11 Office = #1 or #5 ? Telephone Number = #8 ? E-Mail = #3 ? Primary Web Page =
ADDRESS TAB: Street = #6 ? P.O.Box = City = #9 ?? State/province = Zip/Postal code =
http://msdn.microsoft.com/library/defaul...ributes_all.asp #1 buildingName The buildingName attribute type specifies the name of the building where an organization or organizational unit is based. CN buildingName Ldap-Display-Name buildingName #2 Address The user's address. CN Address Ldap-Display-Name streetAddress #3 E-mail-Addresses The list of email addresses for a contact. CN E-mail-Addresses Ldap-Display-Name mail #4 Given-Name Contains the given name (first name) of the user. CN Given-Name Ldap-Display-Name givenName #5 Location The user's location such as office number. CN Location Ldap-Display-Name location #6 Street-Address The street address. CN Street-Address Ldap-Display-Name street #7 Surname This attribute contains the family or last name for a user. CN Surname Ldap-Display-Name sn #8 Telephone-Number The primary telephone number. CN Telephone-Number Ldap-Display-Name telephoneNumber #9 Locality-Name Represents the name of a locality, such as a town or city. CN Locality-Name Ldap-Display-Name l #10 Display-Name The display name for an object. This is usually the combination of the users first name, middle initial, and last name. CN Display-Name Ldap-Display-Name displayName #11 Description Contains the description to display for an object. This value is treated as single-valued by the system. CN Description Ldap-Display-Name description
|
|
Top
|
|
|
|
#152939 - 2005-12-09 01:04 PM
Re: Extracting Info From Active Directory
|
GSUK
Starting to like KiXtart
Registered: 2004-03-10
Posts: 125
|
The easiest way I found the object names was:
Run the CSVDE.exe program (part of the server resource kit) on a DC and export the contents of an OU to a .CSV file. The file will header each column with the object name. Use these names to reference the objects in AD.
Hope this helps.
|
|
Top
|
|
|
|
#152940 - 2005-12-13 02:34 PM
Re: Extracting Info From Active Directory
|
MACE
Starting to like KiXtart
Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
|
Generally things work however I cannot get 'description' to work. Looks like the array is out of bounds for the type of data returned. Can anyone help ? Code:
break on setoption("NoVarInString","Off") include ".\fnLDAPQuery.kix" Global $FullName GLobal $Suffix Global $Title Global $Mobile Global $email Global $Comment $USERNAME="%username%"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext") $strFilter = "(&(objectClass=User)(sAMAccountName="+$USERNAME+"))"
$aAttributes = "sAMAccountName", "displayName" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") $FullName= $aResults[Ubound($aResults),UBound($aResults,2)] $aAttributes = "sAMAccountName", "physicalDeliveryOfficeName" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") $SUFFIX= $aResults[Ubound($aResults),UBound($aResults,2)] ; $aAttributes = "sAMAccountName", "description" ; $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") ;$Title= $aResults[Ubound($aResults),UBound($aResults,2)] $Title=@comment $aAttributes = "sAMAccountName", "telephoneNumber" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") $Mobile= $aResults[Ubound($aResults),UBound($aResults,2)] $aAttributes = "sAMAccountName", "mail" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") $email= $aResults[Ubound($aResults),UBound($aResults,2)] $aAttributes = "sAMAccountName", "wWWHomePage" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"sAMAccountName") $Comment= $aResults[Ubound($aResults),UBound($aResults,2)]
? $FullName+" "+$Suffix ? $Title ? $Mobile ? $email ? $Comment
sleep 10
|
|
Top
|
|
|
|
#152942 - 2005-12-13 05:02 PM
Re: Extracting Info From Active Directory
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
$ldap = TranslateName(1, @domain, 3, @ldomain+'\'+@userid, 1) $OU = LDAPArray($ldap[0],'OU')[1] $UserProperties = GetObject("LDAP://"+$LDAP[0]) $FirstName = $userProperties.FirstName $LastName = $userProperties.LastName $Description = $userProperties.Description $UserProperties = 0
|
|
Top
|
|
|
|
#152945 - 2005-12-20 11:39 PM
Re: Extracting Info From Active Directory
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Does this get you closer to your goal?
Code:
Break on SetOption("NoVarInString","Off") include "K:\Functions\fnLDAPQuery.kix" Global $FullName Global $Suffix Global $Title Global $Mobile Global $email Global $Comment $USERNAME="%username%" $sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext") $strFilter = "(&(objectClass=User)(sAMAccountName="+$USERNAME+"))" $aAttributes = "displayName", "physicalDeliveryOfficeName", "description", "telephoneNumber", "mail", "wWWHomePage" $aResults = fnLDAPQuery($aAttributes,$sADsPath,$strFilter) ? "Fullname: " + $aResults[0,0] ? "Suffix: " + $aResults[0,1] ? "Title: " + IIf(VarType($aResults[0,2]) & 8192,Join($aResults[0,2]),$aResults[0,2]) ? "Mobile: " + $aResults[0,3] ? "Email: " + $aResults[0,4] ? "HomePage: " + $aResults[0,5] ?? "Done." Get $
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|