KickStarter15 Posted October 6, 2020 Share Posted October 6, 2020 Hi Experts, I'm trying to get the full name of the user by using below code (by Jos). I've been using this for 2years now but suddenly as of this day, the fullname will no longer generate in my msgBox. I tried fixing and recoding the below but still no success. $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", "") ;FullName function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc Any advise would be appreciated, Experts. I just need to get the full name of our user. Thanks, KS15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Marc Posted October 6, 2020 Share Posted October 6, 2020 Well, the code works fine and displays the full Name. So I suppose something else must have been changed on your system. What result does the script give? Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
KickStarter15 Posted October 6, 2020 Author Share Posted October 6, 2020 @Marc, yup it's working before but not sure if the @LogonDomain has been changed or something in our system I just got this "MsgBox(0, 'username', 'Error connecting to domain')" when attempting to fix the code. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
water Posted October 6, 2020 Share Posted October 6, 2020 Here it is running as well. If you run the following script you get the full error information written to the console: $oError = ObjEvent("AutoIt.Error", "_COMError") $oUser = ObjGet("WinNT://" & @LogonDomain & "/" & @UserName) If @error Then Exit MsgBox(0, 'Username', 'Error ' & @error & ' connecting to domain!') MsgBox(0, 'Username', $oUser.FullName) $oUser = 0 $oError = ObjEvent("AutoIt.Error", "") Exit Func _COMError($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc caramen 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
KickStarter15 Posted October 7, 2020 Author Share Posted October 7, 2020 @water, here is the testing result with error. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
water Posted October 7, 2020 Share Posted October 7, 2020 Do you run your script from SciTE or as a compiled exe? If it it an exe could you please copy the exe to a local drive and execute it from there? We have a security setting that limits programs to be run from "secure drives" (or whatever it is being called) only. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
KickStarter15 Posted October 8, 2020 Author Share Posted October 8, 2020 @water, this is still in my scite. This was reported to me by our managers that the program is not generating anymore full name during the runtime. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Marc Posted October 8, 2020 Share Posted October 8, 2020 Hm, tried to google for the error code and got some ramblings about enabling/disabling smb v1/2/3. Depending on your environment, it would be possible that the domaincontroller is old (only supporting smbv1) and if you are using windows 10, it would not be able to connect. Just a wild guess... Out of curiousity, what does the following code do on your system? $oError = ObjEvent("AutoIt.Error", "_COMError") $objConnection = ObjCreate("ADODB.Connection") ; Create COM object to AD $objConnection.ConnectionString = "Provider=ADsDSOObject" $objConnection.Open("Active Directory Provider") ; Open connection to AD $user = @UserName $domain = @LogonDNSDomain $strQuery = "<LDAP://" & $domain & ">;(&(objectCategory=person)(objectclass=user)(sAMAccountName=" & $user & "));ADsPath;subtree" $objRecordSet = $objConnection.Execute($strQuery) ; Retrieve the FQDN if it exists If $objRecordSet.RecordCount = 1 Then $ldap_entry = $objRecordSet.fields(0).value $oUsr = ObjGet($ldap_entry) $user = $oUsr.samAccountName $result = $oUsr.sn & ", " & $oUsr.givenName MsgBox(0, "Full Name", $result) EndIf $objConnection.close Func _COMError($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_COMError Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
KickStarter15 Posted October 8, 2020 Author Share Posted October 8, 2020 @Marc, Thank you so much, the code is working fine and generates the fullname. However, how would we know about this smbv1 if it old or not. Anyways, thank you for your time and effort in checking my concern.😊🙏 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Marc Posted October 8, 2020 Share Posted October 8, 2020 Glad I could help. 🙂 About smbv1: If the domain controller is a Server 2003, you'd only be able to use smbv1. from 2008 and above, at least v2 is available. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
water Posted October 8, 2020 Share Posted October 8, 2020 @KickStarter15 If you need more Active Directory functions I suggest to have a look at my AD UDF My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
KickStarter15 Posted October 10, 2020 Author Share Posted October 10, 2020 @Marc yup got it, thanks for the information now I understand it. 👍 @water As always, I'm always sneaking at your UDFs which gives me more ideas and knowledge. I've learned a lot from your UDFs from the very beginning👍😏 but still there are things that I still need help😅 especially the Excel part which is very complex for me... Hehehe Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
water Posted October 10, 2020 Share Posted October 10, 2020 Glad you like my UDFs My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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