Jump to content
Sign in to follow this  

AD: SAM 2 DisplayName

Recommended Posts


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
if $cmdline[0] = 1 Then ConsoleWrite(_SAM2DisplayName($cmdline[1]))

Func _SAM2DisplayName($3LC)
    Local $strdisplayName = "not found"
    Local $objCommand = ObjCreate("ADODB.Command")
    Local $objConnection = ObjCreate("ADODB.Connection")
    Local $objRootDSE = ObjGet("LDAP://RootDSE")
    $objConnection.Provider = "ADsDSOObject"
    $objConnection.Open("Active Directory Provider")
    $objCommand.ActiveConnection = $objConnection
    Local $strBase = "<GC://" & $objRootDSE.Get("defaultNamingContext") & ">"
    Local $strFilter = "(sAMAccountName=" & $3LC & ")"
    Local $strAttributes = "displayName"
    Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree"
    $objCommand.CommandText = $strQuery
    $objCommand.Properties("Page Size") = 100
    $objCommand.Properties("Timeout") = 30
    $objCommand.Properties("Cache Results") = False
    $objCommand.Properties("searchscope") = $ADS_SCOPE_SUBTREE
    Local $objRecordSet = $objCommand.Execute
    While Not $objRecordSet.EOF
        $strdisplayName = $objRecordSet.Fields("displayName").value
    $objConnection = ""
    $objCommand = ""
    $objRecordSet = ""
    $objRootDSE = ""
    Return $strdisplayName
EndFunc   ;==>_SAM2DisplayName

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*ยต&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post

Link to post
Share on other sites

Works brilliantly, thank you!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.