I’m using the IsRoleEnabled method for the aclentry class. However, at one of my roles that I’m checking for, I get a domino designer error that states “Role name [xxx] not found”. It comes up as a message box and halts my code.
Why does it do this instead of just evaluating to false and continuing on?
My line of code is simply:
if aclentry.IsRoleEnabled(“[xxx]”) then
...
I don’t understand - can anyone help?
Bob
Subject: Help with IsRoleEnabled - Role Name not Found error
The message “Role name [xxx] not found” comes if the database does not have the Role which you are checking with NotesACLEntry.IsRoleEnabled().
You can do your own IsRoleEnabled function, which will not give that message box if the role does not exist:
Sub Initialize
Dim session As New notessession
Dim db As NotesDatabase
Set db=session.CurrentDatabase
Set acl=db.acl
Set aclentry=acl.getfirstentry
While Not aclentry Is Nothing
If IsRoleEnabled(aclentry,"[xxx]") Then
' do something here if this ACLEntry has role [xxx] enabled
End If
Set aclentry=acl.getnextentry(aclentry)
Wend
End Sub
Function IsRoleEnabled(aclentry,rolename)
Forall role In aclentry.roles
If role=rolename Then
found=True
Exit Forall
End If
End Forall
IsRoleEnabled=found
End Function
Subject: RE: Help with IsRoleEnabled - Role Name not Found error
Thanks for the code - I may use it - but, the role that gives the error IS in the database ACL.
Subject: RE: Help with IsRoleEnabled - Role Name not Found error
Perhaps your database is corrupted, or you misspelled the Role name.
You could try to remove the role which gives problems and add it again, or even remove all roles and add them all back, or create a new database and copy all design documents and documents over, and add the roles manually.
In either case, I would still use the custom IsRoleEnabled() function to avoid also this kind of problems.