Sign in to follow this  
Followers 0
Jaksa

Ignore error messages

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

Dear Zedna,

it works perfectly.

Thank you very much, you saved my day

Jaksa

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  
Followers 0