Create encrypt replica programmatically

Hi, I created lotus script agent which create local replica from server (via Create Replica method). But this replica is not encrypted by local ID which created it. I need to create encrypted replica by local ID.(same thing as you can do manually via File - Replication - New Replica and then check encryption for database).

Any ideas? Thanks a lot

Subject: Create encrypt replica programmatically

Simple agent which create encypted local replica (no error handling):Option Declare

Private Const wAPIModule = “NNOTES” ’ Windows/32

Private Const NOTE_CLASS_ALL=&H7FFF

Private Const NOTE_CLASS_ALL_PUBLIC=&H06FFF

Private Const NOTE_CLASS_PRIVATE=&H1000

Private Const NOTE_CLASS_ICON=&H0010

Private Const NOTE_CLASS_ACL=&H0040

Private Const NOTE_CLASS_REPLFORMULA=&H0800

Private Const DBCOPY_REPLICA&=&H00000001

Private Const DBCOPY_REPLICA_NAMELIST&=&H01000000

’

Public Const DBCOPY_ENCRYPT_SIMPLE&=&H00000040

Public Const DBCOPY_ENCRYPT_MEDIUM&=&H00000080

Public Const DBCOPY_ENCRYPT_STRONG&=&H00000100

Declare Private Function NSFDbClose Lib wAPIModule Alias “NSFDbClose” _

( Byval hDB As Long) As Integer

Declare Private Function OSPathNetConstruct Lib wAPIModule Alias “OSPathNetConstruct” _

( Byval Path As Long, Byval sServer As String, Byval sFilepath As String, Byval retNetpath As String) As Integer

Declare Function OSLoadString Lib wAPIModule (Byval hModule As Long, Byval iCode As Integer, Byval retBuffer As String, BufferLength As Integer) As Integer

Declare Private Function NSFDbCreateAndCopy Lib wAPIModule Alias “NSFDbCreateAndCopy”( Byval srcDB As Lmbcs String, _

Byval dstDB As Lmbcs String, Byval NoteClass As Integer,Byval limit As Integer, Byval flags As Long, hDB As Long) As Integer

Sub Initialize

Dim s As New NotesSession

Dim newdb As NotesDatabase

Set newdb=CreateLocalReplicaExt(s.CurrentDatabase,DBCOPY_ENCRYPT_STRONG)

If newdb.IsOpen Then

Call s.CurrentDatabase.Replicate(“”)

else

Print “oop’s…”

End If

End Sub

Private Function CreateLocalReplicaExt(db As NotesDatabase, pEncryption As Long) As NotesDatabase

Dim srcpath As String

Dim dstpath As String

Dim hDB As Long

Dim ret As Integer

Dim buf As String

Dim nclass As Integer

Dim flags As Long

Dim dstdb As New NotesDatabase(“”,“”)

If db.server<>“” Then

srcpath=String(1024,0)

dstpath=String(1024,0)

OSPathNetConstruct 0, db.Server, db.FilePath, srcpath

OSPathNetConstruct 0, “”, db.FilePath, dstpath

nclass=NOTE_CLASS_ICON + NOTE_CLASS_REPLFORMULA + NOTE_CLASS_ACL

'too slowly - nclass=NOTE_CLASS_ALL_PUBLIC

flags=DBCOPY_REPLICA + DBCOPY_REPLICA_NAMELIST + pEncryption

ret=NSFDbCreateAndCopy(srcpath,dstpath, nclass, 0, flags ,hDB)

If hDB<>0 Then

NSFDbClose hDB

Call dstdb.Open(“”,db.FilePath)

Else

buf=String$(256, 0)

OSLoadString 0, ret, buf, 255

Print “NSFDbCreateAndCopy:”,ret,buf

End If

Else

Print “source db must be on server”

End If

Set CreateLocalReplicaExt= dstdb

End Function

Enjoy!

Subject: RE: Create encrypt replica programmatically

Mitka, Awesome. It worked like a Charm. Thanks

Raj

Subject: Create encrypt replica programmatically

Yep. We have the same problem:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/c455c9f0a9a1085c85256e2f006fd698?OpenDocument

In 6.5.5 it is not possible to automate the creation of a locally encrypted database. (AFAIK)

Lost suggested running a db.compact after the database is created but it does not work. LotusScript ignore the prefered encryption settings!.

We have had to resort to using the @commands and some very clunkly code with user intrervention to semi-automate local replica being created with encryption.

AJP