Tuesday, March 4, 2014

Lotus script to create adminp deletion from Excel (.CSV) file

 

Requirement (When to use?):

When you have to delete users listed an excel sheet or any .csv convertable file. It can be best useful in mass deletion requirements.

Agent:

Sub Initialize
   
    Dim session As New NotesSession
    Dim db,addbk As NotesDatabase
    Dim usrvw As NotesView
    Dim Username As String
    Dim    delcounter As Integer
   
    Dim nap As NotesAdministrationProcess
    Dim FIleNumber As Integer
    Dim Filename As String
   
    Set db = session.CurrentDatabase   

   
    'Getting Address book.
    Set addbk=session.GetDatabase("Server Name","names.nsf",0)
    'To locally test enter server as blank Ex: "".
    Set usrvw=addbk.getview("$NamesFieldLookup")

    'If $NamesFieldLookup is not in the database, please use the different 'view which is sorted on the name format we have in .csv file.
   
    'Creating a file accesser
    filenumber%=FreeFile()
    fileName$="File Path"
    'Example: D:\usrdel.csv 
    Open fileName For Input As fileNumber%
   
    On Error Resume next
   
    delcounter=0
    Do Until EOF(fileNumber%)
        Input #fileNumber%,Username
        delcounter=delcounter+1
        Call nap.DeleteUser(Username, True , MAILFILE_DELETE_ALL , "Description about deletion",False)
        'notesAdministrationProcess.DeleteUser( username$ , immediate , mailfileaction% , denygroup$ [ , deletewindowsuser ] )
        'mailfileaction% :
        'MAILFILE_DELETE_ALL (2) deletes the mail file On the user's home server and all replicas. 
        'MAILFILE_DELETE_HOME (1) deletes the mail file On the user's home server. 
        'MAILFILE_DELETE_NONE (0) leaves the user's mail file. 
        'Use the required option.
        Print "Deleted " & CStr(delcounter) " Users"
    Loop   
   
End Sub


Notes:

  • You can create this agent in any of the database. (Local or server)
  • Id that sign's agent need to have admin access such that it can raise and adminp request.
  • .CSV file should have complete canonical name of the users.

No comments:

Post a Comment