Page 1 of 1 1
Topic Options
#209478 - 2014-10-03 04:56 AM Active Directory Properties
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Hi

Is there a list of synteax that I can use to call for the fields within the user properties?

Example: Job Title, Department, Company, Telephone Number, etc.

Top
#209479 - 2014-10-03 05:16 AM Re: Active Directory Properties [Re: Jasniel]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
Open aduc.with advanced options and attribute editor tab.
_________________________
!

download KiXnet

Top
#209481 - 2014-10-03 09:30 AM Re: Active Directory Properties [Re: Lonkero]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4671
Loc: The Netherlands
This may also help a bit

 Code:
CLS
Break on
$username = @USERID
$userhome = TranslateName(3, "", 3, @LDomain + "\" + $username, 1)
$userinfo = GetObject("LDAP://" + $userhome[0])

;? "General Info"
;? "------------"
;? " "
? "First Name: " + $userinfo.givenName
? "Initials: " + $userinfo.initials
? "Last Name: " + $userinfo.sn
? "Full Name: " + $userinfo.FullName
? "Display Name: " + $userinfo.displayName
? "Account Name: " + $userinfo.sAMAccountName
? "Distinguished Name: " + $userinfo.distinguishedName
? "Description: " + $userinfo.Description
? "Office Location: " + $userinfo.physicalDeliveryOfficeName
? "Email: " + $userinfo.mail
? "Web Page: " + $userinfo.wwwHomePage
? "Street: " + $userinfo.streetAddress
? "Postal Code: " + $userinfo.postalCode
? "Post Office Box: " + $userinfo.postOfficeBox
? "City: " + $userinfo.l
? "State or Province: " + $userinfo.st
? "Country or Region: " + $userinfo.co
? "Home Phone: " + $userinfo.homePhone
? "Pager: " + $userinfo.pager
? "Mobile Phone: " + $userinfo.mobile
? "Telephone Number: " + $userinfo.telephoneNumber 
? "Fax Number: " + $userinfo.facsimileTelephoneNumber
? "Notes: " + $userinfo.info
? "Title: " + $userinfo.title
? "Department: " + $userinfo.department
? "Company Name: " + $userinfo.company
? "Principal Name: " + $userinfo.userPrincipalName
? " "
? "Profile Info"
? "------------"
? " "
? "Profile Path: " + $userinfo.profilePath
? "Script Path: " + $userinfo.scriptPath
? "Home Directory: " + $userinfo.homeDirectory
? "Home Drive: " + $userinfo.homeDrive
? "Terminal Services Profile Path: " + $userinfo.TerminalServicesProfilePath
? "Terminal Services Local Path: " + $userinfo.TerminalServicesHomeDirectory
? "Terminal Services Home Drive: " + $userinfo.TerminalServicesHomeDrive
? "Terminal Services Allowed: " + $userinfo.AllowLogon
? " "
? "Account Info"
? "------------"
? " "
? "User Account Control: " + $userinfo.userAccountControl
? "Account Disabled: " + $userinfo.AccountDisabled
? "Account Locked: " + $userinfo.IsAccountLocked
? "Account Created: " + $userinfo.whenCreated
? "Account Last Modified: " + $userinfo.whenChanged
? "Account Expires: " + $userinfo.AccountExpirationDate
? "Last Login: " + $userinfo.LastLogin
? "Last Failed Login: " + $userinfo.LastFailedLogin
? "Logon Count: " + $userinfo.logonCount
? "Bad Login Count: " + $userinfo.BadLoginCount
? "Password Last Changed: " + $userinfo.PasswordLastChanged

? 'Press a key...'
Get $

; TranslateName function authored by Howard A. Bullock
Function TranslateName($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
	Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
	Dim $NameTranslate, $ReturnName, $Error, $ErrorText
	$Error = 0
	$ErrorText = ""
	$ReturnName = ""
	$NameTranslate = CreateObject("NameTranslate")
	$Error = @error
	$ErrorText = @serror
	If $Error = 0
		$NameTranslate.Init($InitType, $BindName)
		$Error = @error
		$ErrorText = @serror
		If $Error = 0
			$NameTranslate.Set($LookupNameType, $LookupName)
			$Error = @error
			$ErrorText = @serror
			If $Error = 0
				$ReturnName = $NameTranslate.Get($ReturnNameType)
				$Error = @error
				$ErrorText = @serror
			EndIf
		EndIf
	EndIf
	$TranslateName = $ReturnName, $Error, $ErrorText
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#209482 - 2014-10-03 09:41 AM Re: Active Directory Properties [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1889
Loc: Hilversum, The Netherlands
Talk about silver platters... here's a script I wrote to enumerate all available properties in your AD.

 Code:
ListAdsiToTxt("DOMAIN\username","@SCRIPTDIR\username.txt")

Function ListAdsiToTxt($strADObject, $strLogFile)
  Global $objLog
  Dim $objCN, $objLDAP, $objLDAPSchema, $objFSO, $objProperty
  $objCN = TranslateName($strADObject)
  $objLDAP = GetObject("LDAP://" + $objCN)
  $objLDAPSchema = GetObject($objLDAP.schema)
  $objFSO = CreateObject("Scripting.FileSystemObject")
  $objLog = $objFSO.OpenTextFile($strLogFile, 8, 1)
  $objLog.WriteLine("Mandatory Properties:")
  $objLog.WriteLine("---------------------")
  $objLog.WriteLine("")
  For Each $objProperty In $objLDAPSchema.MandatoryProperties
    If NOT InStr($objProperty,"-")
      $=Execute("$$strPropType=VarTypeName($$objLDAP."+$objProperty+")")
      $=Execute("$$strPropValue=$$objLDAP."+$objProperty)
      $s = ""
      Select
        Case $strPropType = "Object"
          WriteLog($objProperty,$strPropType)
        Case $strPropType = "Variant[]"
          WriteLog($objProperty,$strPropType)
          For Each $item In $strPropValue
            WriteLog("*"+$objProperty,$strPropType,$item)
          Next
        Case $strPropType = "Byte[]"
          $comma = ""
          For $i=0 to Len($strPropValue)
            $s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($strPropValue,$i,1))),2)
            $comma = ","
          Next
          WriteLog($objProperty,$strPropType,$s)
        Case 1
          WriteLog($objProperty,$strPropType,$strPropValue)
      EndSelect
    Else
      WriteLog($objProperty,"N/A")
    EndIf
  Next
  $objLog.WriteLine("")
  $objLog.WriteLine("Optional Properties:")
  $objLog.WriteLine("--------------------")
  $objLog.WriteLine("")
  For Each $objProperty In $objLDAPSchema.OptionalProperties
    If NOT InStr($objProperty,"-")
      $= Execute("$$strPropType=VarTypeName($$objLDAP."+$objProperty+")")
      $= Execute("$$strPropValue=$$objLDAP."+$objProperty)
      $s = ""
      Select
        Case $strPropType = "Object"
          $objDate = Integer8Date($strPropValue)
          WriteLog($objProperty,$strPropType,$objdate)
        Case $strPropType = "Variant[]"
          WriteLog($objProperty,$strPropType)
          For Each $item In $strPropValue
            WriteLog("*"+$objProperty,$strPropType,$item)
          Next
        Case $strPropType = "Byte[]"
          $comma = ""
          For $i=0 to Len($strPropValue)
            $s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($strPropValue,$i,1))),2)
            $comma = ","
          Next
          WriteLog($objProperty,$strPropType,$s)
        Case 1
          WriteLog($objProperty,$strPropType,$strPropValue)
      EndSelect
    Else
      WriteLog($objProperty,"N/A")
    EndIf
  Next
  $objLog.Close
EndFunction

Function WriteLog($LineToWrite,$sType,Optional $sValue)
  Select
    Case Len($sType) < 9
      $sType = $sType+Chr(9)+Chr(9)
    Case Len($sType) >= 9
      $sType = $sType+Chr(9)
    Case 1
      ? "Other Type?"
  EndSelect
  Select
    Case Len($LineToWrite) < 8
      $objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
    Case Len($LineToWrite) >= 8 AND Len($LineToWrite) < 16
      $objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
    Case Len($LineToWrite) >= 16 AND Len($LineToWrite) < 24
      $objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
    Case Len($LineToWrite) >= 24 AND Len($LineToWrite) < 32
      $objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+$sType+$sValue)
    Case Len($LineToWrite) >= 32
      $objLog.WriteLine($LineToWrite+Chr(9)+$sType+$sValue)
    Case 1
      ? "Other Len?"
  EndSelect
EndFunction

Function TranslateName($NameToTranslate)
  Dim $NameTranslate
  $NameTranslate = CreateObject("NameTranslate")
  $NameTranslate.Init(3,"")
  $NameTranslate.Set(3,$NameToTranslate)
  $TranslateName = $NameTranslate.Get(1)
EndFunction

Function Integer8Date($objDate,optional $lngBias)
   Dim $lngHigh,$lngLow,$lngDate,$Pow,$l,$jdate,$lngYear,$lngMonth,$lngDay,$s,$m,$h
   If NOT (VarType($objDate) & 9) Exit 87 EndIf
   If VarType($lngBias)=0
      $lngBias = Val(ReadValue("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\","ActiveTimeBias"))
      If @ERROR Exit @ERROR EndIf
   EndIf
   
   $lngHigh = $objDate.HighPart 
   $lngLow = $objDate.LowPart 
   If $lngLow < 0 $lngHigh=$lngHigh+1 EndIf
   If $lngHigh = 0 AND $lngLow = 0 $lngBias=0 EndIf
   $Pow=2.0
   For $l = 1 to 31 $Pow=2.0*$Pow Next
   $lngDate = ((CDbl($lngHigh)*$Pow+$lngLow)/600000000-$lngBias)/1440 
   If $lngDate > 0
      $jdate = 584389 + Fix($lngDate)
      $lngYear = (100*(((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4))+
         (100*($jdate+306)-25))/36525 
      $lngMonth = (5*(((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4)+
         ($jdate+306)-365*$lngYear-$lngYear/4)+456)/153 
      $lngDay = (((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4)+
         ($jdate+306)-365*$lngYear-$lngYear/4)-(153*$lngMonth-457)/5 
      If $lngMonth>12 $lngYear=$lngYear+1 $lngMonth=$lngMonth-12 EndIf 
      $lngMonth = Right("0"+$lngMonth,2) 
      $lngDay = Right("0"+$lngDay,2) 
      
      $s = Fix(86400.0 * ($lngDate-Fix($lngDate)))
      $m = $s / 60
      $s = $s mod 60
      $h = $m / 60
      $m = $m mod 60
      $Integer8Date=''+$lngYear+'/'+$lngMonth+'/'+$lngDay+' '+$h+':'+Right("0"+$m,2)+':'+Right("0"+$s,2)
   EndIf
EndFunction

Top
#209484 - 2014-10-03 10:07 AM Re: Active Directory Properties [Re: Arend_]
Jasniel Offline
Getting the hang of it

Registered: 2000-04-08
Posts: 77
Thanks for all your help.
Top
#209502 - 2014-10-06 10:05 PM Re: Active Directory Properties [Re: Jasniel]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11616
Loc: CA
Thanks for Dinner Arend :-)
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 294 anonymous users online.
Newest Members
MacduMela, karimKix, NicoK, Kelly001, MichaelK72
17776 Registered Users

Generated in 0.064 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org