LotusScript to C API Programming Guide

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

Anonymous

login


 

Hosted by Prominic.NET, Inc.
Main topic: using ACLLookupAccess . . .

using ACLLookupAccess . . . (by Dallas Gimpel, 05/27/2005 11:04:34 AM)

Hi Normunds -

Sorry for the delayed response. Here's what I've done in the interim. Since you stated that it was working for you with your name defined in the ACL (as mine is) I first took your code and converted it to use my declarations, which worked without a problem.

Then I copied your code into a separate module and re-confirmed that it worked when called.

Next, I began changing the newly created module to accept handles obtained in my code as parameters. So I first began passing MY database handle to the function, then I began passing MY database handle and MY ACL handle, etc, so that I now pass the database handle, the ACL handle, and a pointer to the NAMES_LIST structure, all of which are obtained in MY code. When structured this way (ie, the call to ACLLookupAccess is separated into its own module and passed its parameters), the ACLLookupAccess call works and finds the correct access level for my name. But if I make the call to ACLLookupAccess in the same module with the same handles, it returns the default access level to the database??? So here's my code in its current form along with the newly created module containing the call to ACLLookupAccess. Any idea what's going on here??? Maybe I'm doing something stupid -- I just don't see it!

Oh, and incidentally, this definitely only works if my name is explicitly defined in the ACL. It does not find my access by way of public groups to which I belong - interesting to me because NSFDbAccessGet _does_.

Function validateAccess() As Boolean

   On Error Goto errorHandler

   

   Dim nsess As NotesSession

   Dim lngHDb As Long

   Dim lngHACL As Long

   Dim lngHNameList As Long

   Dim lngNamesLock As Long   

   Dim lngHPrvNames As Long

   Dim lngPrivileges As Long

   Dim intRC As Integer

   Dim intMaxAxsLvl As Integer

   Dim intAxsLvl As Integer

   Dim intAxsFlags As Integer

   Dim strUName As String

   Dim strMsgTxt As String

   Dim strPath As String * 256

   Dim varNames As Variant

   

   validateAccess = False

   Set nsess = New NotesSession

   strUName$ = nsess.UserName

   

'//   get a handle to the current database

   Call W32OSPathNetConstruct(0, nsess.CurrentDatabase.Server, nsess.CurrentDatabase.FilePath, strPath$)

   intRC% = W32NSFDbOpen(strPath$, lngHDb&)

   If Not(intRC% = 0) Then

      Call getAPIErrorDesc(intRC%, strMsgTxt$)

      Error intRC%, strMsgTxt$

   End If

   

'//   get a handle to the ACL of the current database

   intRC% = W32NSFDbReadACL(lngHDb&, lngHACL&)

   If Not(intRC% = 0) Then

      Call getAPIErrorDesc(intRC%, strMsgTxt$)

      Error intRC%, strMsgTxt$

   End If

   

'//   get a handle to the NAMES_LIST structure for the current user

   intRC% = W32NSFBuildNamesList(strUName$, 0&, lngHNameList&)

   If Not(intRC% = 0) Then

      Call getAPIErrorDesc(intRC%, strMsgTxt$)

      Error intRC%, strMsgTxt$

   End If

   

'//   store a pointer to the memory location of the NAMES_LIST structure

   lngNamesLock& = W32OSLockObject(lngHNameList&)

   

   intAxsLvl% = getAccessLevel(lngHDb&, lngHACL&, lngNamesLock&)

   

'   intRC% = W32ACLLookupAccess(lngHACL&, aclNameList, intAxsLvl%, lngPrivileges&, intAxsFlags%, lngHPrvNames)

'   intRC% = W32ACLLookupAccess(lngHACL&, lngNamesLock&, intAxsLvl%, lngPrivileges&, intAxsFlags%, lngHPrvNames&)

   If Not(intRC% = 0) Then

      Call getAPIErrorDesc(intRC%, strMsgTxt$)

      Error intRC%, strMsgTxt$

   End If

   

   Msgbox "Access level detected: " & intAxsLvl%, , "DEBUG . . ."

   

functionExit:

   strMsgTxt$ = "Cleanup results:"

   

   If Not(lngNamesLock& = 0) Then

      Call W32OSUnlockObject(lngHNameList&)

      lngNamesLock& = 0

   End If

   

   If Not(lngHNameList& = 0) Then

      Call W32OSMemFree(lngHNameList&)

      lngHNameList& = 0

   End If

   

   If Not(lngHPrvNames& = 0) Then

      Call W32OSMemFree(lngHPrvNames&)

      lngHPrvNames& = 0

   End If

   

   If Not(lngHACL& = 0) Then

      Call W32OSMemFree(lngHACL&)

      lngHACL& = 0

   End If

   

   If Not(lngHDb& = 0) Then

      Call W32NSFDbClose(lngHDb&)

      lngHDb& = 0

   End If

   Exit Function

   

errorHandler:

   Msgbox "Error " & Err & ": " & Error$ & " at line " & Erl & " of " & Getthreadinfo(1) & ".", , "Error encountered . . ."

   Print "Error " & Err & ": " & Error$ & " at line " & Erl & " of " & Getthreadinfo(1) & " . . ."

   Resume functionExit

End Function

Function getAccessLevel(plngHDb As Long, plngHACL As Long, plngNamesLock As Long) As Integer

   Dim hPrivNames As Long

   Dim intRC As Integer

   Dim intAxsLevel As Integer

   Dim privileges As Long

   Dim accessFlags As Integer

   

   intRC% = W32ACLLookupAccess(plngHACL, plngNamesLock, intAxsLevel, privileges, accessFlags, hPrivNames)

   If intRC% = 0 Then

      Call W32OSMemFree(hPrivNames)

   End If

   getAccessLevel% = intAxsLevel%

End Function