Sunday, April 29, 2012

Updating the ACL to the existing databases in the server

Sub Initialize
    Dim session As new NotesSession
    Dim curdb As NotesDatabase
    Dim prfvw As NotesView
    Dim pdoc As NotesDocument
    Dim entryvw As NotesView
    Dim entrydoc As NotesDocument
   
    Dim filedb As NotesDatabase
    Dim acl As NotesACL
    Dim aclentry1 As NotesACLEntry
    Dim aclentry2 As NotesACLEntry
    Dim aclentry3 As NotesACLEntry
   
    Set curdb=session.Currentdatabase
    Set prfvw = curdb.Getview("Profile")
    Set pdoc=prfvw.Getfirstdocument()
   

    Dim dbdir As New NotesDbDirectory(pdoc.pab_server(0))
    Dim db As NotesDatabase
    Set db=dbdir.Getfirstdatabase(DATABASE)
   
    Do Until DB Is Nothing
        Dim item As NotesItem
        Set item=pdoc.Getfirstitem("strFolder")
       
        ForAll x In item.Values

            If Left(db.FilePath,Len(x))= x Then
                Dim tempdb As NotesDatabase
                Set tempdb=session.Getdatabase(pdoc.pab_server(0),db.FilePath)
                Set acl =tempdb.Acl
               
                Set entryvw=curdb.Getview("ACLEntry")
                Set entrydoc=entryvw.Getfirstdocument()
               
               
                Set aclentry1=acl.Getentry(entrydoc.o_grp1(0))
                If Not aclentry1 Is Nothing Then
                    aclentry1.Name=entrydoc.n_grp1(0)
                    Call acl.Save()
                End If
               
                Set aclentry2=acl.Getentry(entrydoc.o_grp2(0))
                If Not aclentry2 Is Nothing Then
                    aclentry2.Name=entrydoc.n_grp2(0)
                    Call acl.Save()
                End If
               
                Set aclentry3=acl.Getentry(entrydoc.o_grp3(0))
                If Not aclentry3 Is Nothing Then
                    aclentry3.Name=entrydoc.n_grp3(0)
                    Call acl.Save()
                End If
               
            End If
           
        End ForAll
       
        Set db=dbdir.Getnextdatabase()
    Loop
   
   
End Sub

No comments:

Post a Comment