How to remove "Enforce uniform/consistent access" flag even without access to the database!

This tip describes how to remove the remove "Enforce uniform/consistent access" flag without access to the database.

If you have ever faced the problem of a lost database due to an erroneous ACL and "Enforce a consistent ACL across all replicas" was set...

You may still recover this database by running this script locally on the affected machine.

Actually, althought direct access and LotusScript access are denied, programs written with Notes API, can access and change this flag.

Below is the code (hope will help... it should!).

You can create an EXE file to convert this into a tool (I did but I can't submit it here)...


*---------------------------------------------------
'* RemoveUnifAccess. Last updated by: Pierre JANDOT [PJandot@lyon.micropole-univers.com] 06/10/2002
'*
'* Removes the "Uniform access" ACL flag, even from
'* a database you can't access...
'*---------------------------------------------------
Option Public
Option Declare

'*------------------------------------------------------------
'* API declaration
'*------------------------------------------------------------

'*-- nNotes DLL: Open database
Declare Private Function NSFDbOpen Lib "nNotes" Alias "NSFDbOpen" (_
Byval dbname As Lmbcs String,_
dbhandle As Long )_
As Integer

'*-- nNotes DLL: Read a database's ACL
Declare Private Function NSFDbReadACL Lib "nNotes" Alias "NSFDbReadACL" (_
Byval dbhandle As Long,_
rethACL As Long )_
As Integer

'*-- nNotes DLL: Get ACL general flags
Declare Private Function ACLGetFlags Lib "nNotes" Alias "ACLGetFlags" (_
Byval hACL As Long,_
Flags As Long )_
As Integer

'*-- nNotes DLL: Set ACL general flags
Const ACL_UNIFORM_ACCESS = &h00000001
Declare Private Function ACLSetFlags Lib "nNotes" Alias "ACLSetFlags" (_
Byval hACL As Long,_
Byval Flags As Long )_
As Integer

'*-- nNotes DLL: Write a database's ACL
Declare Private Function NSFDbStoreACL Lib "nNotes" Alias "NSFDbStoreACL" (_
Byval dbhandle As Long,_
Byval hACL As Long,_
Byval objid As Long,_
Byval meth As Integer ) _
As Integer 

'*-- nNotes DLL: Free memory
Declare Private Function OSMemFree Lib "nNotes" Alias "OSMemFree" (_
Byval hmem As Long )_
As Integer

'*-- nNotes DLL: Close database
Declare Private Function NSFDbClose Lib "nNotes" Alias "NSFDbClose" (_
Byval dbhandle As Long )_
As Integer

'*-- nLib DLL: String function
Const ERR_MASK = &h3FFF
Declare Private Function OSLoadString Lib "NLib.DLL" (_
Byval hmod As Long,_
Byval coderr As Integer,_
Byval liberr As String, _
Byval lgbuf As Integer ) As Integer

Sub Initialize

On Error Goto AbnormalTerm

'*-- Designate (local) database to open
Dim bastoproc As String
bastoproc$ = Inputbox$ ( "Local database to process:",_
"Remove uniform access", "" )
If bastoproc$ = "" Then Exit Sub

'*-- Open database
Dim errmsg As String
Dim hdb As Long
If OpenDB% ( "", bastoproc$, hdb&, errmsg$ ) = False Then _
Goto AbnormalTerm

'*-- Get ACL
Dim retcod As Integer
Dim hACL As Long
retcod% = NSFDbReadACL ( hdb&, hACL& )
If (retcod% <> 0) Then Goto AbnormalTerm

'*-- Get ACL flags
Dim flags As Long
retcod% = ACLGetFlags ( hACL&, flags& )
If (retcod% <> 0) Then Goto AbnormalTerm

'*-- Remove "Uniform access" flag
flags& = flags& And (Not ACL_UNIFORM_ACCESS)
retcod% = ACLSetFlags ( hACL&, flags& )
If (retcod% <> 0) Then Goto AbnormalTerm

'*-- Write back ACL
retcod% = NSFDbStoreACL ( hdb&, hACL&, 0&, 0 )
If (retcod% <> 0) Then Goto AbnormalTerm

'*-- Free ACL object memory
retcod% = OSMemFree ( hACL& )
If (retcod% <> 0) Then Goto AbnormalTerm

'*-- Close database
If CloseDB% ( hdb&, errmsg$ ) = False Then Goto AbnormalTerm

Exit Sub

AbnormalTerm :
If errmsg$ = "" Then
If (retcod% <> 0) Then
errmsg$ = "ERR: " & GetErrLib$ ( retcod% )
Else
errmsg$ = "ERR: " & Error$ & " (l=" & Erl & ")"
End If
End If
Msgbox errmsg$
If hdb& <> 0 Then Call CloseDB% ( hdb&, errmsg$ )
Exit Sub

End Sub

'*========================================
'* Call : OpenDB, CloseDB
'* Get text associated with an error code
'*----------------------------------------
Function GetErrLib (_
errcod As Integer ) _ ' Error code
As String ' Returned error text
'*========================================

'*-- Get error text
Dim retlen As Integer
Dim errlib As String
errlib$ = String ( 256, 0 )
retlen% = OSLoadString ( 0, (errcod% And ERR_MASK), errlib$, 255 )

GetErrLib$ = "0x" & Hex$ ( errcod% ) & "= '" &_
Mid$ ( errlib$, 1, retlen% ) & "'"

End Function '* GetErrLib

'*=============================================
'* Call : Initialize
'* Opens a database
'*---------------------------------------------
Function OpenDB (_
serv As String,_ ' Server name
chem As String, _ ' File access to database
hdb As Long,_ ' Returned handle
msgerr As String ) _ ' Possible error
As Integer ' True iif OK
'*=============================================

OpenDB% = False

'*-- Construct access
Dim netpath As String
If Len (serv$) > 0 Then
netpath$ = serv$ & "!!" & chem$
Else
netpath$ = chem$
End If

'*-- Open
Dim retcod As Integer
retcod% = NSFDbOpen ( netpath$, hdb )
If (retcod% <> 0) Then
msgerr$ = "ERR: " & GetErrLib$ ( retcod% )
Exit Function
End If

OpenDB% = True

End Function '* OpenDB

'*=================================================
'* Call : Initialize
'* Closes a database
'*-------------------------------------------------
Function CloseDB (_
hdb As Long,_ ' Handle of database to close
msgerr As String ) _ ' Possible error
As Integer ' True iif OK
'*=================================================

CloseDB% = False

'*-- Fermer
Dim retcod As Integer
retcod% = NSFDbClose ( hdb& )
If (retcod% <> 0) Then
msgerr$ = "ERR: " & GetErrLib$ ( retcod% )
Exit Function
End If

CloseDB% = True

End Function '* CloseDB
  
This was first published in October 2002
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close