Queener

Return login user full name

6 posts in this topic

#1 ·  Posted (edited)

Can someone help me with this?

 

I used this code, but unfortunately when the message prompt, it's doesn't return any value. I tried change the @LogonDomain to my localhost name or just localhost, but not work.

 

$oMyError = ObjEvent("AutoIt.Error", "ComError")
$UserObj = ObjGet("WinNT://" & @LogonDomain & "/" & @UserName)
If @error Then
    MsgBox(0, 'username', 'Error connecting to domain')
Else
    MsgBox(0, 'username', $UserObj.FullName)
EndIf
$UserObj = ""
$oMyError = ObjEvent("AutoIt.Error", "")
;COM Error function
Func ComError()
    If IsObj($oMyError) Then
        $HexNumber = Hex($oMyError.number, 8)
        SetError($HexNumber)
    Else
        SetError(1)
    EndIf
    Return 0
EndFunc  ;==>ComError

lRK4c8.jpg

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites



@Queener, AutoIt built-in macros @LogonDomain and @UserName contain that information, so what exactly are you looking for?

Share this post


Link to post
Share on other sites

@Username populate the login name and not the full name in AD.


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites

if the computer @LogonDomain is not identical to the user domain in AD, then use the Active Directory UDF - it has just the function you need.

Share this post


Link to post
Share on other sites

Function _AD_GetObjectAttribute should return the required information.
Run example script _AD_GetObjectProperties.au3 to get a list of available properties.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

sounds good, will give it a try and keep you guys in the loop.


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

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