Jaksa Posted January 15, 2007 Share Posted January 15, 2007 Hello, I wrote a small script which read some information from Active Directory: Const $ADS_NAME_INITTYPE_GC = 3 Const $ADS_NAME_TYPE_NT4 = 3 Const $ADS_NAME_TYPE_1779 = 1 $objRootDSE=ObjGet("LDAP://RootDSE") $strDNSDomain = $objRootDSE.Get("defaultNamingContext") $objTrans=ObjCreate("NameTranslate") $objTrans.Init($ADS_NAME_INITTYPE_GC, "" ) $objTrans.Set($ADS_NAME_TYPE_1779, $strDNSDomain) $strNetBIOSDomain = $objTrans.Get($ADS_NAME_TYPE_NT4) $strNetBIOSDomain =StringLeft($strNetBIOSDomain,StringLen($strNetBIOSDomain)-1) $objTrans.Set($ADS_NAME_TYPE_NT4, $strNetBIOSDomain & "\" & @UserName) $strUserDN = $objTrans.Get($ADS_NAME_TYPE_1779) $objUser = ObjGet("LDAP://" & $strUserDN) MsgBox(0,"Info",$objuser.Get("displayName")) MsgBox(0,"Info",$objuser.Get("initials")) This script works fine as long as the fields are filled in the Active Directory. Some users have the field Initials empty. In this case I get an error message: C:\Documents and Settings\admin-GER\Desktop\test.au3 (17) : ==> The requested action with this object has failed.: MsgBox(0,"Info",$objuser.Get("initials")) ^ ERROR How can I ignore error messages? I tried it with $oMyError = ObjEvent("AutoIt.Error","nothing"), but it doesnt work. Any hints? Best Regards Jaksa Link to comment Share on other sites More sharing options...
Vindicator209 Posted January 15, 2007 Share Posted January 15, 2007 If your looking to jump past the error, and move on to the rest of the script, then you minds well just take it out of your script...because that part of the script wont work either way... [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Zedna Posted January 16, 2007 Share Posted January 16, 2007 Try this: $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $output = $objuser.Get("initials") If @error Then ... Func MyErrFunc() ; when COM/Obj error then only set flag and do nothing SetError(1) EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Jaksa Posted January 16, 2007 Author Share Posted January 16, 2007 Dear Zedna, it works perfectly. Thank you very much, you saved my day Jaksa 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