Home All Groups Group Topic Archive Search About

can't disable shift key with faq_DisableShiftKeyBypass function

Author
4 Jan 2009 11:12 AM
jaworski_m
hello,
I use the function "faq_DisableShiftKeyBypass " described in "SECFAQ.doc" by
Microsoft.

I am logged in as database owner (also a memer of Admins group), have full
permissions. Database is secured, database name isn't misspelled when calling
the function, path to database is correct.

When calling the function I get the error message "Function
DisableShiftKeyBypass did not complete successfully", which means the
property was not created.

However, when I use the function to disable a different (also secured)
database it works as it should.

What might be the problem?

Thank you for hints.

Author
4 Jan 2009 5:57 PM
Chris O'C via AccessMonster.com
That function fails if the db is already opened exclusively or if you're not
joined to the secure workgroup when running the function.  I'd suggest
stepping through the function in the debug window to see which line of code
fails and sends you to the error handler.

Chris


jaworski_m wrote:
Show quoteHide quote
>hello,
>I use the function "faq_DisableShiftKeyBypass " described in "SECFAQ.doc" by
>Microsoft.
>
>I am logged in as database owner (also a memer of Admins group), have full
>permissions. Database is secured, database name isn't misspelled when calling
>the function, path to database is correct.
>
>When calling the function I get the error message "Function
>DisableShiftKeyBypass did not complete successfully", which means the
>property was not created.
>
>However, when I use the function to disable a different (also secured)
>database it works as it should.
>
>What might be the problem?
>
>Thank you for hints.

Author
4 Jan 2009 9:14 PM
jaworski_m
Chris, thank you for reply.

I posted the code of the "faq_DisableShiftKeyBypass" (below) for reference
of discussion.

> That function fails ... if you're not joined to the secure workgroup when running
> the function.
I executed the function from inside the secured database just to make sure
if I am connected to the correct workgroup. It didn't work.

> I'd suggest stepping through the function in the debug window to see which line of > code fails and sends you to the error handler.
I did according to your suggestions. The error is triggered in the line
marked <BREAKPOINT> (code below)

> That function fails if the db is already opened exclusively.
After your suggestions I tried opening the database exclusively. Function
WORKED.
Running the "faq_DisableShiftKeyBypass" function from SEPARATE
*ShiftByPass.mdb* file (containing module with the function) WORKED ONLY when
this separate file was also opened exclusively.

Correct me if I'm wrong. Does this function execute ONLY when a database is
opened exclusively?

**** CODE START (faq_DisableShiftKeyBypass) ****
Function faq_DisableShiftKeyBypass(strDBName As String, fAllow As Boolean)
As Boolean

    On Error GoTo errDisableShift

    Dim ws As Workspace
    Dim db As Database
    Dim prop As Property
    Const conPropNotFound = 3270

    Set ws = DBEngine.Workspaces(0)
<BREAKPOINT>    Set db = ws.OpenDatabase(strDBName)

    db.Properties("AllowByPassKey") = Not fAllow
    faq_DisableShiftKeyBypass = fAllow
exitDisableShift:
Exit Function

errDisableShift:
    'The AllowBypassKey property is a user-defined
    ' property of the database that must be created
    ' before it can be set. This error code will execute
    ' the first time this function is run in a database.

    If Err = conPropNotFound Then
    ' You must set the fourth DDL parameter to True
    ' to ensure that only administrators
    ' can modify it later. If it was created wrongly, then
    ' delete it and re-create it correctly.
    Set prop = db.CreateProperty("AllowByPassKey", _
        dbBoolean, False, True)
        db.Properties.Append prop
        Resume
    Else
        MsgBox "Function DisableShiftKeyBypass did not complete successfully."
        faq_DisableShiftKeyBypass = False
        GoTo exitDisableShift
    End If
End Function
**** CODE END ****
Author
5 Jan 2009 5:49 AM
Chris O'C via AccessMonster.com
The function works for me when I already have the target db opened in shared
mode.  Something about your target db file is requiring you to open it
exclusively when you open it with the opendatabase method.  Hard to pin down
what though.

I'd suggest opening the db in exclusive mode to change its shiftkeybypass
property.  At least you know that works for this db.

Chris


jaworski_m wrote:

Show quoteHide quote
>I posted the code of the "faq_DisableShiftKeyBypass" (below) for reference
>of discussion.
>
>> That function fails ... if you're not joined to the secure workgroup when running
>> the function.
>I executed the function from inside the secured database just to make sure
>if I am connected to the correct workgroup. It didn't work.
>
>> I'd suggest stepping through the function in the debug window to see which line of > code fails and sends you to the error handler.
>I did according to your suggestions. The error is triggered in the line
>marked <BREAKPOINT> (code below)
>
>> That function fails if the db is already opened exclusively.
>After your suggestions I tried opening the database exclusively. Function
>WORKED.
>Running the "faq_DisableShiftKeyBypass" function from SEPARATE
>*ShiftByPass.mdb* file (containing module with the function) WORKED ONLY when
>this separate file was also opened exclusively.
>
>Correct me if I'm wrong. Does this function execute ONLY when a database is
>opened exclusively?

--
Message posted via http://www.accessmonster.com