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.

Saturday, March 1, 2014

Notes script to run archival, Incremental backup, full backup scripts of the domino server.


Requirement (When to use?):

Below is an interesting simple script that can run the archival, Incremental backup, full backup scripts of listed domino servers (TSM TDP).

All we have to do is to give the script path in the code.

Agent:

Sub Initialize
    Dim session As New notessession
    Dim curdb As NotesDatabase
    Set curdb=session.CurrentDatabase
   
'Give the Script path in below. Example script paths would be:
'Example: C:\Program Files\Tivoli\TSM\domino\doarch.cmd
'Example: C:\Program Files\Tivoli\TSM\domino\dosel.cmd

       result = Shell("Script path", 1)
             If result=33 Then
            Print "Successfully triggered the backup"
end if
    
End Sub

Notes:
  • Running another script is an restricted operation. So the server should allow the id to run restricted operations.
    • Check below settings:




      • On the server document
      • Navigate to the 'Security' Tab
      • Update the "Sign or run unrestricted methods and operations:" with the id or the server names.
      • Save & Close the server document. 
  • On the agent properties:
      • second tab(Access)
      • Set run time security level:
        • Select allow restricted operations. 
  • You can Schedule this agent, according to the requirement.
  • Similar agent can be used for running any other scripts on the server.