LotusScript to C API Programming Guide

rtLib Domino Rich Text Management template
Show details for ContentContent
Ready-to-use samples
Show details for Online resourcesOnline resources
Happy readers




Hosted by Prominic.NET, Inc.
Main topic: Problems with SecAttachFileToDB

Problems with SecAttachFileToDB (by Leif lagebrand, 09/15/2006 03:40:49 AM)

Im trying to securely attach an ID file via the SecAttachFileToDB method. As I'm new to this I get the little red crash notice when I try to run it.

I have read the C Api documentations and the kfm.h header file of the SECAttachFileToDB and cant see that there are any special considerations. But I still doesnt get it to work.

Any suggestions is greatly appreciated.


In the code below I have omitted most declarations (as I have determined that they work).

Declare Function SECAttachIdFileToDB Lib "nnotes" Alias "SECAttachIdFileToDB" (hdb As Long, Byval ProfileNotesName As _

Lmbcs String, Byval ProfileNoteNameLength As Long, Byval UserName As Lmbcs String, Byval UserNameLength As Long, _

Byval FileName As Lmbcs String, Byval Password As Lmbcs String, Byval Reserved As Long, Byval pReserved As _

Lmbcs String) As Integer

Sub Initialize


   On Error Goto errorHandler


   Dim ses As New NotesSession

   Dim db As NotesDatabase

   Dim PortName As String

   Dim ServerName As String

   Dim FileName As String

   Dim pathName As String*1024

   Dim ret As Integer

   Dim hdb As Long

   Dim ProfileNoteName As String

   Dim LmbcsLen As Long

   Dim memMan As New memoryManagerExt

   Dim pLmbcsStr As Long

   Dim IdFileName As String

   Dim password As String

   Dim empty As String

   Dim zero As Long



   empty = ""

   zero = 0

   Set db = ses.CurrentDatabase


   ' Construct the path to this database

   PortName = ""

   ServerName = db.Server

   FileName = db.FilePath

   ret = PathNetConstruct(PortName, ServerName, FileName, pathName)

   If ret <> 0 Then Error 1212, "Something went amiss"


   ' Open database to get a handle opn it

   ret = NSFDbOpen(pathName, hdb)

   If ret <> 0 Then Error 1212, "Something went amiss"


   ProfileNoteName = "test"

   pLmbcsStr = memMan.newBuffer (3 * Lenb(ProfileNoteName))


   LmbcsLen = TranslateFromStr(OS_TRANSLATE_UNICODE_TO_LMBCS, ProfileNoteName, Lenb(ProfileNoteName), _

   pLmbcsStr, 3 * Lenb(ProfileNoteName))


   IdFileName = "c:\hto.id"

   Password = "******" ' Correct pwd for stated id file


   ret = SECAttachIdFileToDB(hdb, ProfileNoteName, LmbcsLen, empty, zero, _

   IdFileName, Password, zero, empty)

   If ret <> 0 Then Error 1212, "Something went amiss"


   ' Close the database to free its resources

   ret = NSFDbClose(hdb)

   If ret <> 0 Then Error 1212, "Something went amiss"




   Exit Sub




   Print Error$ + " in line " + Cstr(Erl)

   Messagebox Error$ + " in line " + Cstr(Erl)

   Resume exitOk


End Sub