@UserRoles en Ls
la fonction renvois tous les roles de la LCA avec true si lapersonne a le role et false si elle ne l'a pas
- Code : Tout sélectionner
Function UserRoles_LS(wnmUser As NotesName) As Variant
'Indique pour l'utilisateur si il a ou pas le role déclaré dans la LCA de la base
'chaque role de la base est passé en renvu. si le role est a true, l'utilsateur à le role si le role est a false l'utilsateur n'a pas le role
'Déclaration des Variables
Dim Session As NotesSession
Dim DB As NotesDatabase
Dim lstUR List As Integer
Dim ACL As NotesACL
Dim ACLEntry As NotesACLEntry
On Error Goto ErreurUserRoles_LS
lstUR("0") = False
If wnmUser Is Nothing Then
UserRoles_LS = lstUR
Exit Function
End If
Set Session = New NotesSession
Set DB = Session.CUrrentdatabase
Set ACL = Nothing
Set ACL = DB.ACL
If ACL Is Nothing Then
UserRoles_LS = lstUR
Exit Function
End If
lstUR("DBAccess") = db.CurrentAccessLevel
Forall Value In ACL.Roles
lstUR(Strleft(Strright(Trim(Cstr(Value)),"["),"]")) = False
End Forall
Set ACLEntry = Nothing
Set ACLEntry = ACL.GetEntry(wnmUser.Common)
If ACLEntry Is Nothing Then
Set ACLEntry = ACL.GetEntry(wnmUser.Abbreviated)
If ACLEntry Is Nothing Then
Set ACLEntry = ACL.GetEntry(wnmUser.Canonical)
If ACLEntry Is Nothing Then
Set ACLEntry = ACL.GetfirstEntry()
If ACLEntry Is Nothing Then
UserRoles_LS = lstUR
Exit Function
End If
End If
End If
End If
If ACLEntry Is Nothing Then
UserRoles_LS = lstUR
Else
lstUR("0") = True
Forall Value In ACLEntry.Roles
lstUR(Strleft(Strright(Trim(Cstr(Value)),"["),"]")) = True
End Forall
UserRoles_LS = lstUR
End If
Set ACL = Nothing
Set ACLEntry = Nothing
Erase lstUR
Exit Function
ErreurUserRoles_LS:
Msgbox "(UserRoles_LS) Erreur " + Str(Err) + " : " + Cstr(Error)+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
lstUR("0") = False
UserRoles_LS = lstUR
Erase lstUR
Exit Function
End Function