rogerd2u Posted March 24, 2006 Share Posted March 24, 2006 (edited) Do any of you know how to get a users "full name"? So, for instance, Bob Smith's login name is "bsmith" I would like to display a splash screen saying something to the effect of, "Hello, Bob Smith!" As you know, the Macro, @UserName, only gives the login name. There is a "Full Name" description for all our user accounts, but I can't find a way to pull from that field. We are in a Windows 2003 domain. If anyone has been successful in getting this to work, would you please post your code? Thanks in advance! Roger Edited March 24, 2006 by rogerd2u Roger O."When people show you who they are, believe them. --Mark Twain Link to comment Share on other sites More sharing options...
Developers Jos Posted March 24, 2006 Developers Share Posted March 24, 2006 Beta required: $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 AnonymousX 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rogerd2u Posted March 24, 2006 Author Share Posted March 24, 2006 Awesome! Thanks so much, JdeB! That is exactly what I needed. Roger Roger O."When people show you who they are, believe them. --Mark Twain Link to comment Share on other sites More sharing options...
rogerd2u Posted March 24, 2006 Author Share Posted March 24, 2006 Now, can you tell me how I could use this script so that I could just get the users First name? Roger O."When people show you who they are, believe them. --Mark Twain Link to comment Share on other sites More sharing options...
GaryFrost Posted March 24, 2006 Share Posted March 24, 2006 Now, can you tell me how I could use this script so that I could just get the users First name? you could do something like $oMyError = ObjEvent("AutoIt.Error", "ComError") $UserObj = ObjGet("WinNT://" & @LogonDomain & "/" & @UserName) If @error Then MsgBox(0, 'username', 'Error connecting to domain') Else $Name = StringSplit($UserObj.FullName, " ") MsgBox(0, 'username', "First Name: " & $Name[2] & @CRLF & "Last Name: " & $Name[1]) 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 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
rogerd2u Posted March 24, 2006 Author Share Posted March 24, 2006 Thanks, gafrost! Roger O."When people show you who they are, believe them. --Mark Twain Link to comment Share on other sites More sharing options...
Developers Jos Posted March 24, 2006 Developers Share Posted March 24, 2006 (edited) Now, can you tell me how I could use this script so that I could just get the users First name? If you want what is defined in the AD you can do it this way. This will give you access to lots of AD information...See here for details Const $ADS_NAME_INITTYPE_GC = 3 Const $ADS_NAME_TYPE_NT4 = 3 Const $ADS_NAME_TYPE_1779 = 1 $oMyError = ObjEvent("AutoIt.Error", "ComError") $objRootDSE = ObjGet("LDAP://RootDSE") If @error Then MsgBox(0, 'username', 'Error connecting to domain') Else ; DNS domain name. $objTrans = ObjCreate("NameTranslate") $objTrans.Init ($ADS_NAME_INITTYPE_GC, "") $objTrans.Set ($ADS_NAME_TYPE_1779, @LogonDomain) $objTrans.Set ($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & @UserName) $strUserDN = $objTrans.Get ($ADS_NAME_TYPE_1779) $UserObj = ObjGet("LDAP://" & $strUserDN) If @error Then MsgBox(0, 'username', 'Error connecting to domain') Else MsgBox(0, 'username', $UserObj.FullName & " Firstname:" & $UserObj.FirstName) EndIf 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 Edited March 24, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 24, 2006 Developers Share Posted March 24, 2006 $Name = StringSplit($UserObj.FullName, " ") MsgBox(0, 'username', "First Name: " & $Name[2] & @CRLF & "Last Name: " & $Name[1]) The issue with this solution is when people have double lastnames and/or middle initials ...... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GaryFrost Posted March 24, 2006 Share Posted March 24, 2006 The issue with this solution is when people have double lastnames and/or middle initials ...... thanks, you might also want to add some string replacement for special chars in it for example ours has location/company in the name so.... $strUserDN = StringReplace($objTrans.Get ($ADS_NAME_TYPE_1779),"/","\/") SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 24, 2006 Developers Share Posted March 24, 2006 thanks, you might also want to add some string replacement for special chars in it for example ours has location/company in the name so.... $strUserDN = StringReplace($objTrans.Get ($ADS_NAME_TYPE_1779),"/","\/") I cannot test it now, but i thougth that this statement retrieved the fully qualified domainname which is needed to be able to use the LDAP com object. Are you saying it is not working the way I coded it and the slashes need to be prefixed with a backslash for the LDAP object retrieval to work ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
GaryFrost Posted March 24, 2006 Share Posted March 24, 2006 I cannot test it now, but i thougth that this statement retrieved the fully qualified domainname which is needed to be able to use the LDAP com object. Are you saying it is not working the way I coded it and the slashes need to be prefixed with a backslash for the LDAP object retrieval to work ?yep, was getting an error, took a few minutes to figure out the slash was the problem SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Sundance Posted April 4, 2006 Share Posted April 4, 2006 (edited) Hiho, is there a way to see all possible infos about the user? More than just the FullName. (Ex.: SID) $UserObj. ??? Haven't found something on microsoft.com. Only for WMI services... greets an thx in advance Sundance OKAY i should better read the answers !! haven't seen the link from JdeB. :-) (but there's also no option for the SID...) Finally i got it with WMI-Services.. :-)) Edited April 4, 2006 by Sundance Link to comment Share on other sites More sharing options...
djek Posted May 4, 2006 Share Posted May 4, 2006 Hiho,is there a way to see all possible infos about the user? More than just the FullName. (Ex.: SID)$UserObj. ???Haven't found something on microsoft.com. Only for WMI services...Finally i got it with WMI-Services.. :-))Would you mind posting that? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now