ReplicateWithServer LS to API code problem

Hi all,

I am trying to create a replica of the Personal Address Book onto a server.

Error : 5646

I am struggling to troubleshoot this error message. Any ideas?

Option Public

Option Declare

'Declarations*

'STATUS LNPUBLIC ReplicateWithServer(char far *PortName,char far *ServerName,WORD Options,WORD NumFiles,const char far *FileList,REPLSERVSTATS far *retStats);

%REM

#define REPL_OPTION_RCV_NOTES 0x00000001 /* Receive notes from server (pull) */

#define REPL_OPTION_SEND_NOTES 0x00000002 /* Send notes to server (push) */

#define REPL_OPTION_ALL_DBS 0x00000004 /* Replicate all database files */

#define REPL_OPTION_CLOSE_SESS 0x00000040 /* Close sessions when done */

#define REPL_OPTION_ALL_NTFS 0x00000400 /* Replicate NTFs as well */

#define REPL_OPTION_PRI_LOW 0x00000000 /* Low, Medium, & High priority databases*/

#define REPL_OPTION_PRI_MED 0x00004000 /* Medium & High priority databases only*/

#define REPL_OPTION_PRI_HI 0x00008000 /* High priority databases only*/

%END REM

'LotusScript code**

Public Const REPL_OPTION_RCV_NOTES& = &H00000001

Public Const REPL_OPTION_SEND_NOTES& = &H00000002

Type REPLSERVSTATS

Pull As Variant

Push As Variant

StubsInitialized As Long

TotalUnreadExchanges As Long

NumberErrors As Long

LastError As Integer

End Type

Type pREPLSERVSTATS

Pull As REPLSERVSTATS

Push As REPLSERVSTATS

End Type

Declare Function W32_ReplicateWithServer Lib “nnotes.dll” Alias “ReplicateWithServer” _

(Byval PortName As Lmbcs String, _

Byval ServerName As Lmbcs String, _

Byval Options As Integer, _

Byval NumFiles As Integer, _

Byval FileList As String,_

retStats As pREPLSERVSTATS) As Integer

Dim Result As Long

Dim PortName As String

Dim ServerName As String

Dim Options As Integer

Dim NumFiles As Integer

Dim FileList As String

Dim retStats As Long

Dim repStats As pREPLSERVSTATS

Sub Initialize

PortName = "TCPIP"

ServerName = "CN=popper/OU=servers/OU=london/O=glen"





Options = 2

'REPL_OPTION_RCV_NOTES Or REPL_OPTION_SEND_NOTES

FileList = "bbnabs\pthomas\names.nsf"

result = W32_ReplicateWithServer( PortName,ServerName, Options,1,FileList, repStats)

If (result <> False) Then

	Msgbox "Error: " & result

End If

End Sub

Help !!

Paul

Subject: My guess is that there is not a replica of the File on the server you are trying to replicate with.

Subject: ReplicateWithServer LS to API code problem

Bill is right. You can use the function below (or some variation of it) to gather additional information about the return code from the API. So if I use it and plug in your return code as follows:

Dim intErrCode As Integer

Dim strErrTxt As String



intErrCode% = 5646

Call getAPIErrorDesc(intErrCode%, strErrTxt$)

Msgbox "Error " & intErrCode% & ": " & strErrTxt$ & ".", , "DEBUG . . ."

Print "Error " & intErrCode% & ": " & strErrTxt$ & " . . ."

The message text I get back is “None of the selected databases has a replica on the server”.

hth,

dgg

Declare Function W32OSLoadString Lib “nnotes” Alias “OSLoadString” ( _

Byval hMod As Long, _

Byval stringCode As Integer, _

Byval retBuff As Lmbcs String, _

Byval buffLen As Integer _

) As Integer

Private Sub getAPIErrorDesc(pintRetCode As Integer, pstrErrMsg As String)

'// +++ GLOBAL VARIABLES +++

'// Constants:

'// <add global constants, if any, here>

'//

'// Class instances:

'// <add global class instances, if any, here>

'//

'// 08/09/2002 - Dallas Gimpel

'//

'// DESCRIPTION:

'// This sub takes the unmodified return code returned by an api call and “decodes” it

'// into a more familiar error number. It then returns the text associated with the given

'// error number by making an api call which loads the text into a string variable. If

'// no text is returned for the given error, it defaults to “unknown error”.

'//

'// INPUT:

'// pintRetCode - Integer, the original return code as returned from the api call

'//

'// OUTPUT:

'// pintRetCode - Integer, modified by “Anding” the error mask to it to produce a “kinder & gentler” error

'// pstrErrMsg - String, the text of the error message as returned by the api

Const NULL_HANDLE = 0&

Const ERROR_MASK = &H3fff '// see globerr.h

Const BUFFER_SIZE% = 255

Const UNKOWN_ERR_DESC$ = "unknown error"

Dim intLength As Integer



pstrErrMsg$ = String$(BUFFER_SIZE + 1, 0)

pintRetCode% = pintRetCode% And ERROR_MASK

intLength% = W32OSLoadString(NULL_HANDLE, pintRetCode%, pstrErrMsg$, BUFFER_SIZE)



If intLength% > 0 Then '// if we get a valid error description back, use it

	pstrErrMsg$ = Fulltrim(pstrErrMsg$)

Else

	pstrErrMsg$ = UNKOWN_ERR_DESC

End If

End Sub

Subject: RE: ReplicateWithServer LS to API code problem

OK,

I am getting error 15740

You are not authorised to replicate or copy data from this database

I have full Mangler Access with all roles.

This error occurs if run on the Server replica or on the Local Replica

Any Ideas

Subject: RE: ReplicateWithServer LS to API code problem

Hi all,

OK, I was under the impression that the code would create the replica if none existed.

Anyway, I have created the replica. The code returns no error now, but does absolutely nothing.

Am I missing something?

P.S All I need to do is get a user to click on a button. It…

1/ Amends the ACL of their Personal NAB - Done

2/ Amends the Locations Doc for Replication - Done

3/ Creates a replica on their local server - Done

4/ PROBLEM - Adds the replication to the replicator page.

Any ideas?

Subject: RE: ReplicateWithServer LS to API code problem

Put the server name explicitly in the ACL of the local replica. R6 quirk.

By the way, you could have done this via the NotesDatabase.Replicate() method in LotusScript as well.

e.g.

Set dbReplica = New NotesDatabase(“”, “”)

Call dbReplica.Open(“”, strReplicaDb)

If (dbReplica.IsOpen()) Then

‘’‘’ ’ must use canonical format here as of R6.53

intReturnValue = dbReplica.Replicate(nnServerName.Canonical)

End If

Subject: RE: ReplicateWithServer LS to API code problem

Hi Timothy,

This is still not working. I am using the following code. Am I going mad?

	Set dbreplica = New NotesDatabase("", "names.nsf")

		Set replica = dbreplica.CreateReplica(conservname, path)

		Call workspace.AddDatabase(conservname, path)

		Call workspace.OpenDatabase(conservname, path)

		flag = dbreplica.Replicate( conservname )

Subject: RE: ReplicateWithServer LS to API code problem

Quick overview…

createReplica() will fail if the file already exists. Use it if there is no replica in place.

Use replicate() if the replica is in place already.

replicate() only works if the replica server is listed explicity in the ACL of the local replica in either abbreviated or canonical format.

AKA. “LocalDomainServers” is not sufficient.

replicate() only works if the server name parameter is in canonical format.

You may need to verify the server is the ACL in LotusScript after the

Set replica = dbreplica.CreateReplica(…) call.

If not, create the entry.

e.g. something like:

Dim nnServerName as NotesName

Dim acl As NotesACL

Dim entry As NotesACLEntry

Dim conservername as String

Set dbreplica = New NotesDatabase(“”, “names.nsf”)

Set nnServerName = New NotesName(conservname)

conservername = nnServerName.canonical

if (Not (dbreplica.IsOpen)) Then Call dbReplica.open(dbReplica.serverName, dbReplica.FilePath)

Set acl = dbReplica.ACL

Set entry = acl.GetEntry(conservername )

If (entry is Nothing) Then

Set entry = New NotesACLEntry( acl, conservername, ACLLEVEL_MANAGER )

call acl.save()

End If

Set replica = dbreplica.CreateReplica(conservername, path)

Call workspace.AddDatabase(conservername, path)

Call workspace.OpenDatabase(conservername, path)

flag = dbreplica.Replicate( conservername)

(untested)