Break on
DEL "Props.txt"
$rc=SETOPTION ("WrapAtEOL","ON")
Dim $NameArray
$NameArray = TranslateName (3, "", 3, "@ldomain\Howard.Bullock", "1,2")
if @error=0
$UserDN = $NameArray[1]
$UserCanonicalname = $NameArray[2]
? "UserDN = " + $UserDN ?
? "UserCanonicalname = " + $UserCanonicalname ?
WriteLog2("Props.txt", "UserDN = " + $UserDN)
WriteLog2("Props.txt", "UserCanonicalname = " + $UserCanonicalname)
WriteLog2("Props.txt","")
else
? @serror
endif
? ?
$object = getobject("LDAP://" + substr(%LogonServer%,3) + "/"+$UserDN)
EnumObjProps($object)
;--------------------------------------------------------------------------------------------------
;FUNCTION EnumObjProps()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
Function EnumObjProps($object)
Dim $Class, $Schema, $Value, $property, $cont
$Class = GetObject($object.schema)
? "Class: " + $Class.Name
WriteLog2("Props.txt", "Class: " + $Class.Name)
? "GUID: " + $Class.GUID
WriteLog2("Props.txt", "GUID: " + $Class.GUID)
? "Implemented by: " + $Class.CLSID
WriteLog2("Props.txt", "Implemented by: " + $Class.CLSID)
If $Class.Container
? ? "Container Object"
WriteLog2("Props.txt", "Container Object")
? "Class Contains:"
WriteLog2("Props.txt", "Class Contains:")
For Each $cont In $Class.Containment
? " " + $cont
WriteLog2("Props.txt", " " + $cont)
Next
Else
? ? "Leaf Object"
WriteLog2("Props.txt", "Leaf Object")
EndIf
? "Mandatory Properties in this Class: "
For Each $property In $Class.MandatoryProperties
? " " + $property
$val =""
if $property <> "nTSecurityDescriptor" and
$property <> "objectClass"
$RC=EXECUTE("$$VAL = $$object.$property")
" " +$val
WriteLog2("Props.txt", $property + " = " + $val)
endif
Next
? ? "Optional Properties in this Class: "
For Each $property In $Class.OptionalProperties
? " " + $property
$val =""
if $property <> "logonHours" and
$property <> "dSCorePropagationData" and
$property <> "accountExpires" and
$property <> "badPasswordTime" and
$property <> "lastLogoff" and
$property <> "lastLogon" and
$property <> "lockoutTime" and
$property <> "memberOf" and
$property <> "pwdLastSet" and
$property <> "uSNChanged" and
$property <> "uSNCreated" ;and
;left($property, 5) <> "mS-DS"
$RC=EXECUTE('$$VAL = $$object.get("$property")')
" = " + $val
endif
WriteLog2("Props.txt", $property + " = " + $val)
Next
EndFunction
;--------------------------------------------------------------------------------------------------
;FUNCTION TranslateName()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
;
;VERSION 3.0
;
;ACTION Translates from one name type to another. Good for converting an NT4 name
; like domain\user into an LDAP distinguished name or the reverse.
;
;SYNTAX TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
;
;DATE 2005/04/22
;
;PARAMETERS $InitType (Required)
; - Integer value
; 1 = ADS_NAME_INITTYPE_DOMAIN
; Initializes a NameTranslate object by setting the domain that the object will bind to.
;
; 2 = ADS_NAME_INITTYPE_SERVER
; Initializes a NameTranslate object by setting the server that the object will bind to.
;
; 3 = ADS_NAME_INITTYPE_GC
; Initializes a NameTranslate object by locating the global catalog that the object will bind to.
;
; $BindName (Required)
; - String value
; If an $InitType = 3 (ADS_NAME_INITTYPE_GC), then the $BindName = "".
; InitTypes 1 and 2 require a name of a domain or server to be input. Note: "" may default
; to the current server or domain.
;
; $LookupNameType (Required)
; - Integer value
;
; $LookupName (Required)
; - String value see below
;
; $ReturnNameType (Required)
; - single Integer or comma separated string of numbers
;
; Documentation of Name Types. Lookup the more info on http://MSDN.Microsoft.com
; Not all name types work. The two that have been most useful to are "1" and "3"
;
; 1 = ADS_NAME_TYPE_1779
; Name format as specified in RFC 1779. For example, "CN=Jane Doe,CN=users, DC=Microsoft, DC=com".
;
; 2 = ADS_NAME_TYPE_CANONICAL
; Canonical name format. For example, "Microsoft.com/Users/Jane Doe".
;
; 3 = ADS_NAME_TYPE_NT4
; Account name format used in Microsoft® Windows© NT® 4.0. For example, "Microsoft\JaneDoe".
;
; 4 = ADS_NAME_TYPE_DISPLAY
; Display name format. For example, "Jane Doe".
;
; 5 = ADS_NAME_TYPE_DOMAIN_SIMPLE
; Simple domain name format. For example, "JaneDoe@Microsoft.com".
;
; 6 = ADS_NAME_TYPE_ENTERPRISE_SIMPLE
; Simple enterprise name format. For example, "JaneDoe@Microsoft.com".
;
; 7 = ADS_NAME_TYPE_GUID
; Global Unique Identifier format. For example, {95ee9fff-3436-11d1-b2b0-d15ae3ac8436}.
;
; 8 = ADS_NAME_TYPE_UNKNOWN
; Unknown name type. The system will try to make the best guess.
;
; 9 = ADS_NAME_TYPE_USER_PRINCIPAL_NAME
; User principal name format. For example, "JaneDoe@Fabrikam.com".
;
; 10 = ADS_NAME_TYPE_CANONICAL_EX
; Extended canonical name format. For example, "Microsoft.com/Users Jane Doe".
;
; 11 = ADS_NAME_TYPE_SERVICE_PRINCIPAL_NAME
; Service principal name format. For example, "www/www.microsoft.com@microsoft.com"
;
; 12 = ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME
; A SID string, as defined in the Security Descriptor Definition Language (SDDL), for either
; the SID of the current object or one from the object's SID history.
; For example, "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)" For more information see
; Security Descriptor String Format under "Security" in the Microsoft Platform SDK documentation.
;
;REMARKS Not all name types seem to work. $ReturnNameType can be a single number or a comma separated
; list of numbers. The resulting array will have the coresponding array elements populated
; with the specific names requested.
;
;RETURNS This function returns a 13 element ARRAY. Use the array element that corresponds to the
; number of the name type listed above.
;
;DEPENDENCIES OS: Active Directory aware client
;
;EXAMPLES
;
; These two examples attempt to retrieve all names
; $Names = TranslateName (3, "", 3, @Domain + "\" @wksta + "$", "1,2,3,4,5,6,7,8,9,10,11,12")
; Dim $x
; ? "Ubound = " + ubound($names)
; for $x=0 to ubound($Names)
; ? ""+ $x +": " + $Names[$x]
; next
; ?
; $Names = TranslateName (3, "", 3, @LDomain + "\" + @userid, "1,2,3,4,5,6,7,8,9,10,11,12")
; Dim $x
; ? "Ubound = " + ubound($names)
; for $x=0 to ubound($Names)
; ? ""+ $x +": " + $Names[$x]
; next
;
; Get Distinguished Name (Name type #1)
; $Names = TranslateName (3, "", 3, @LDomain + "\" + @userid, 1)
; ? "DN = " + $Names[1]
;
;
Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
Dim $NameTranslate, $Error, $ErrorText, $ReturnNameArray[12], $GetNameArray, $value
$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
Dim $index
$GetNameArray = split($ReturnNameType, ",")
for $index=0 to ubound($GetNameArray)
$value = $GetNameArray[$index]
$ReturnNameArray[$value] = $NameTranslate.Get($value)
next
else
WriteLog("TranslateName SET Error: (" + $Error + ") " + $ErrorText)
exit $Error
endif
else
WriteLog("TranslateName INIT Error: (" + $Error + ") " + $ErrorText)
exit $Error
endif
else
WriteLog("TranslateName CREATEOBJECT Error: (" + $Error + ") " + $ErrorText)
exit $Error
endif
$TranslateName = $ReturnNameArray
Exit 0
Endfunction
;--------------------------------------------------------------------------------------------------
;FUNCTION WriteLog2()
;
;AUTHOR Howard A. Bullock (hbullock@tycoelectronics.com)
;
;ACTION Generic logging facility for scripts. Appends log entry to a file with an
; optional TimeStamp.
;
;SYNTAX WriteLog2($File, $text, [0|1])
;
;PARAMETERS $File (Required) - String value
; $text (Required) - String value
; $TimeStamp (Optional) Default(0) no TimeStamp (1 or 0)
;
;
;REMARKS This function writes (appends) an optionally time stamped log entry to the file
; defined in function. This function searches for the first unused file handle,
; open the file, and write the entry. The file handle is then closed. When the
; function is unable to perform its it write the error is displayed in a message box.
;
;RETURNS Nothing
;
;DEPENDENCIES None
;
;EXAMPLES WriteLog2("junk.txt","This is a test")
; WriteLog2("junk.txt","This is a test",0)
; WriteLog2("junk.txt","This is a test",1)
;
;
Function WriteLog2($File, $Text, optional $TimeStamp)
dim $RC, $File, $text, $FH, $TimeStamp, $nul
$FH=1
$RC=Open ($FH, $File, 5)
while $RC = -3 and $FH < 11
$FH=$FH +1
$RC=Open ($FH, $File, 5)
Loop
Select
Case $RC=0
if ($TimeStamp=1)
$TimeStamp = @Date + " " + @Time + " - "
else
$TimeStamp = ""
endif
$RC=Writeline ($FH, $TimeStamp + $Text + @CRLF)
if ($RC <> 0)
$text = "WriteLine error: $RC @CRLF -4 = File not open for writing@CRLF" +
" -3 = File number not open@CRLF -2 = Invalid file number specified@CRLF" +
" -1 = End of file"
$nul=MessageBox ($text,"Script Error",48)
endif
$nul=Close ($FH)
exit $RC
Case $RC=-2
$text = "WriteLog2: Invalid file handle ($FH) specified when trying to Open $File."
$nul=MessageBox ($text,"Script Error",48)
Case $RC=-1
$text = "WriteLog2: Invalid file name ($File) specified for log file."
$nul=MessageBox ($text,"Script Error",48)
Case $RC=>0
$text = "System Error($RC) while attempting to open log file ($File)."
$nul=MessageBox ($text,"Script Error",48)
Endselect
exit $RC
EndFunction