CreateAdminpMailFile...11/11/2004 05:07:07 PM
I'm surprised that with the registration object, that there is not a method for creating an AdminP request to create a mail file. I guess that it really isn't used that much, so didn't justify spending time coding it.
Well, I wanted it so I wrote a small function to create this request.
I wanted something to do a mass user registration, but didn't want to wait for the mail file to be created by the workstation running the agent. The two documents being passed in to the function are just for pulling the values to populate the AdminP request.
Here it is(you will have to add your own error handling):
Public Function CreateAdminpMailFile( lo_persondoc As NotesDocument, lo_configdoc As NotesDocument ) As Boolean
Dim lo_adminpdb As NotesDatabase
Dim lo_adminpdoc As NotesDocument
Dim lo_item As NotesItem
Dim lo_name As NotesName
Dim ls_username As String
Set lo_adminpdb = go_session.GetDatabase( lo_configdoc.RegServer( 0 ), "admin4.nsf" )
Set lo_adminpdoc = lo_adminpdb.CreateDocument
lo_adminpdoc.Form = "AdminRequest"
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyAction", "24")
lo_item.IsSigned = True
lo_item.IsProtected = True
lo_item.IsSummary = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyAuthor", go_session.EffectiveUserName,AUTHORS )
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyDatabasePath","mail\" & lo_persondoc.Shortname( 0 ) & ".nsf")
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxySourceServer", lo_persondoc.DominoMailServer( 0 ), NAMES)
lo_item.IsSigned = True
Set lo_name = go_session.CreateName( lo_configdoc.RegServer( 0 ) )
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyServer", lo_name.Canonical, NAMES )
lo_item.IsSigned = True
If lo_persondoc.MiddleInitial( 0 ) = "" Then
ls_username = lo_persondoc.Firstname( 0 ) & " " & lo_persondoc.Lastname( 0 )
Else
ls_username = lo_persondoc.Firstname( 0 ) & " " & lo_persondoc.MiddleInitial( 0 ) & " " & lo_persondoc.Lastname( 0 )
End If
Set lo_name = go_session.CreateName( ls_username )
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyNameList", lo_name.Canonical ,NAMES)
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyOriginatingAuthor", go_session.EffectiveUserName, AUTHORS)
lo_item.IsSigned = True
Set lo_item = New Notes
Item( lo_adminpdoc, "Pr
oxyOriginatingOrganization", go_session.EffectiveUserName, AUTHORS)
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyOriginatingTimeDate", Now)
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "FullName", go_session.EffectiveUserName, AUTHORS )
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyProcess", "Adminp" )
lo_item.IsSigned = True
lo_item.IsProtected = True
lo_item.IsSummary = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyMailfileAccessDisplay", "2")
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "CreateFullTextIndex", "0")
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyTextItem1", "mail6.ntf" )
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "$OnBehalfOf", go_session.EffectiveUserName,AUTHORS )
lo_item.IsSigned = True
Set lo_item = New NotesItem( lo_adminpdoc, "ProxyDatabaseName", lo_persondoc.Shortname( 0 ) )
lo_item.IsSigned = True
lo_item.IsSummary = True
lo_adminpdoc.Type = "AdminRequest"
Call lo_adminpdoc.Sign
Call lo_adminpdoc.Save( True, False )
CreateAdminpMailFile = True
End Function