Monday, April 30, 2012

Retriving the ACL Entry Information for each access level for the mail db


Dim levelConstant As Integer

    Dim curDB As NotesDatabase
    Dim profilevw As NotesView
    Dim profiledoc As NotesDocument
    Dim personDB As NotesDatabase
    Dim persondoc As NotesDocument
    Dim caldoc As NotesDocument
   
    Dim LogDoc As NotesDocument
    Dim ActivityLogRTItem As NotesRichTextItem
Sub Initialize
On Error GoTo ErrorHandler
    Dim session As New NotesSession   
    Dim m As Integer
    Dim d As Integer
    Dim e As Integer
    Dim a As Integer
    Dim r As Integer
    Dim w As Integer
    Dim n As Integer
   
    e=1
    m=1
    d=1
    a=1
    r=1
    w=1
    n=1
   
    ReDim editor(1)
    ReDim manager(1)
    ReDim designer(1)
    ReDim author(1)
    ReDim reader(1)
    ReDim depositor(1)
    ReDim noaccess(1)
   
    Set curDB=session.Currentdatabase
   
    Set LogDoc=curDB.CreateDocument
    LogDoc.Form="LogForm"   
    LogDoc.Server=curdb.Server
    LogDoc.StartTime=Now
    Set ActivityLogRTItem = New NotesRichTextItem( LogDoc, "Rtxtlogactivity" )
    Call ActivityLogRTItem.AppendText( Now+ ": "&"Agent Started")
    Call ActivityLogRTItem.AddNewLine( 1)
   
    Set profilevw=curDB.Getview("Profile")
    Set profiledoc=profilevw.Getfirstdocument()
   
    While Not profiledoc Is Nothing
        Set personDB=session.Getdatabase(profiledoc.mailserver(0), profiledoc.folder(0)+"\"+profiledoc.mailfile(0))
        Set caldoc=personDB.GetProfileDocument("CalendarProfile")
       
        Set persondoc = curDB.CreateDocument
        persondoc.Form="PersonInfo"
        persondoc.txt_mailfile=profiledoc.folder(0)+"\"+profiledoc.mailfile(0)
        persondoc.txt_mailowner=caldoc.Owner(0)
       
        'ACL
        Dim Acl As NotesACL
        Dim Aclentry As NotesACLEntry
        Set Acl=personDB.Acl
        Set Aclentry=Acl.Getfirstentry()
       
        While Not Aclentry Is Nothing
           
            If (Aclentry.Level = ACLLEVEL_MANAGER) Then
                manager(m-1)=Aclentry.Name
                m=m+1
                ReDim Preserve manager(m)
                persondoc.txt_manager=manager
               
               
               
            ElseIf (Aclentry.Level = ACLLEVEL_DESIGNER) Then
                designer(d-1)=Aclentry.Name
                d=d+1
                ReDim Preserve designer(d)
                persondoc.txt_designer=designer
               
            ElseIf ((Aclentry.Level = ACLLEVEL_EDITOR))Then
                editor(e-1)=Aclentry.Name
                e=e+1
                ReDim Preserve editor(e)
                persondoc.txt_editor=editor
            ElseIf ((Aclentry.Level = ACLLEVEL_AUTHOR))Then   
                author(a-1)=Aclentry.Name
                a=a+1
                ReDim Preserve author(a)
                persondoc.txt_author=author
               
            ElseIf ((Aclentry.Level = ACLLEVEL_READER))Then
                reader(r-1)=Aclentry.Name
                r=r+1
                ReDim Preserve reader(r)
                persondoc.txt_reader=reader
               
               
            ElseIf ((Aclentry.Level = ACLLEVEL_DEPOSITOR))Then
                depositor(w-1)=Aclentry.Name
                w=w+1
                ReDim Preserve depositor(w)
                persondoc.txt_depositor=depositor
               
               
            ElseIf ((Aclentry.Level = ACLLEVEL_NOACCESS))Then
                noaccess(n-1)=Aclentry.Name
                n=n+1
                ReDim Preserve noaccess(n)
                persondoc.txt_noaccess=noaccess
                           
            End If
           
            Set Aclentry = acl.GetNextEntry( Aclentry )
           
           
        Wend
        Call persondoc.Save(True,False)   
        profiledoc.flag="Yes"
        Call profiledoc.Save(True,False)
       
        Call ActivityLogRTItem.AppendText( Now+ ": "&  "  Mail information retrived from :" & profiledoc.mailfile(0) )
        Call ActivityLogRTItem.AddNewLine( 1)
        Call ActivityLogRTItem.AppendText( Now+ ": "&"Agent Ended")
        Call ActivityLogRTItem.AddNewLine( 1)
        Call LogDoc.Save(True,False)
        Dim temp As NotesDocument
        Set temp=profiledoc
        Call profilevw.Refresh()
       
        Set profiledoc=profilevw.Getfirstdocument()
        ReDim editor(1)
        ReDim manager(1)
        ReDim designer(1)
        ReDim author(1)
        ReDim reader(1)
        ReDim depositor(1)
        ReDim noaccess(1)
        e=1
        m=1
        d=1
        a=1
        r=1
        w=1
        n=1
       
    Wend
    Exit Sub
   
    MsgBox "Completed"
   
   
   
ErrorHandler:
    Call ActivityLogRTItem.AppendText( Now+ ": "&" Error in  :" +profiledoc.mailfile(0))
    Call ActivityLogRTItem.AppendText( Now+ ": Error " & Err() & ": " & Error() & "error line:" & CStr(Erl()))
    Call ActivityLogRTItem.AddNewLine( 1)
    Call LogDoc.Save(True,False)
    Resume Next
    'Exit sub
End Sub

No comments:

Post a Comment