Option Public
'------
%INCLUDE "lsconst.lss"
%INCLUDE "lserr.lss"
Const cServer = "CN=medweb/O=DomainExt"
Const cType = "AdminRequest"
Const cProxyProcess = "AdminP"
Const cProxyAction = "24"
Const cTemplate = "dwa7.ntf"
Const cQuota = 50
Const cWarning = 40
Const cProxyCreateFullTextIndex = 0
Const cOrganization = "DomainExt"
Const cEditor = 2
Const cMailDomain = "@partners.domain.org"
'------
Sub Initialize
On Error Goto processError
Dim session As New NotesSession
Dim AddressDb As NotesDatabase
Dim docs As NotesDocumentCollection
Dim AddressDoc As NotesDocument
Dim AdminDb As New NotesDatabase(cServer, "admin4.nsf")
Dim AdminDoc As NotesDocument
Dim item As NotesItem
Dim sName As String, mailDb As String
Set AddressDb = session.CurrentDatabase
Set docs = AddressDb.UnprocessedDocuments
Set AddressDoc = docs.GetFirstDocument()
fProxyAuthor = session.Username
'------
Do While Not (AddressDoc Is Nothing)
sName = AddressDoc.ShortName(0)
mailDb = "mail" + sName
Set AdminDoc = AdminDb.CreateDocument
Call AdminDoc.Replaceitemvalue ("Form", cType)
Set item = AdminDoc.Replaceitemvalue ("ProxyProcess", cProxyProcess)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyAuthor", fProxyAuthor)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyAction", cProxyAction)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyServer", cServer)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxySourceServer", cServer)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyTextItem1", cTemplate)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyDatabasePath", mailDb)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyNameList", AddressDoc.FullName(0))
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyNumItem1", cQuota)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyNumItem2", cWarning)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyCreateFullTextIndex", cProxyCreateFullTextIndex)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyOverrideDefaultDatastore", cProxyOverrideDefaultDatastore)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyMailfileAccessLevel", cEditor)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyOriginatingAuthor", fProxyAuthor)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("$OnBehalfOf", fProxyAuthor)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("FullName", fProxyAuthor)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyOriginatingTimeDate", Now)
item.IsSigned=True
Set item = AdminDoc.Replaceitemvalue ("ProxyOriginatingOrganization", cOrganization)
Set item = AdminDoc.Replaceitemvalue ("Type", cType)
item.IsProtected = True
Call AdminDoc.Sign
Call AdminDoc.Save (False, False)
Call AdminDoc.ReplaceItemValue("ProxyOriginatingRequestUNID", AdminDoc.UniversalID)
Call AdminDoc.Sign
Call AdminDoc.Save (False, False)
Call AddressDoc.Replaceitemvalue ("MailDomain", cOrganization)
Call AddressDoc.Replaceitemvalue ("MailFile", mailDb)
Call AddressDoc.Replaceitemvalue ("MailServer", cServer)
Call AddressDoc.Replaceitemvalue ("MailSystem", "1")
Call AddressDoc.Replaceitemvalue ("InternetAddress", sName + cMaildomain)
Call AddressDoc.Save (False, False)
Nextdb:
Set AddressDoc = docs.GetNextDocument(AddressDoc)
Loop
Exit Sub
processError:
Messagebox "Error stop: " + AddressDoc.ShortName, MB_ICONSTOP, "Create mail files"
Print "Agent encountered error: " & Err() & " : " & Error() & Str$(Erl())
' Resume Nextdb
Exit Sub
End Sub