Lapas

Wednesday 10 February 2010

Signing LN databases with Server ID with lotusscript

Sometimes for automation tasks developers need to perform design signing with server ID.
Lotus design updates consists of design refresh and aftersigning. Refresh could be automated by using Lotus C API (write request if you need info) and no Server signing functionality.
We have only some methods to do signing:
1. NotesDatabase.sign(), which works with only user ID and on UI
2. NotesDocument.sign() if we are getting design element by noteID or through NotesNoteCollection. It could be signed, but lastmodifed username will remain the same, so you will need to call signing agent twice 1. sign signing agent, 2. sign other database
3. Using admin requests database. This method is better if admin has normal access rights to perform such operations. You'll simply need to create admin request document for each database to be signed, then wait till things is done.
4. Sign using NotesAdministrationProcess class.
Here is sample code for request document. Check "admin4.nsf" on server, where to create request:


Dim sName As Variant
Dim uname As string
sName=Evaluate("@servername",reqDoc) 'db.server does not returns full server name
uname=s.Effectiveusername
With reqDoc
.Form="AdminRequest"
.FullName=uname
.ProxyAction="101" '// action for request - type of request. see admin4.nsf for more info in ProxyAction shared field
.ProxyAuthor=uname
.ProxyDatabasePath=signDB.FilePath
.ProxyNameList=signDB.Title
.ProxyOriginatingAuthor=s.effectiveusername
.ProxyOriginatingOrganization=nname.Organization
.ProxyOriginatingRequestUNID=reqDoc.universalid
.ProxyOriginatingTimeDate=Now
.ProxyProcess="Adminp"
.ProxyServer=sName(0)
.ProxyTextItem1="0"
.Type="AdminRequest"
Call .Replaceitemvalue("$OnBehalfOf", uname)
ForAll cItem In reqDoc.items
cItem.isSigned=True
End ForAll
Call .Sign()
Call .Save(True,True)
End With