Spurious Access passwords

runfineline

New member
Local time
Today, 07:16
Joined
Oct 10, 2007
Messages
4
2 of my Access databases have added password access where I hav'nt put passwords in myself.

Upon trying to open the database I get Password required - enter database password. I am sure I never added password security to this database.
Does anyone else have this experience?
Access added the password itself!
 
I've never come accross this before. In order to add a password you need to open the db in exclusive mode then add the password.

a database password is easy to find out. There are many 'out there'.

here is one
Code:
Public Sub test()
    Debug.Print StPasswordOfStDatabase("S:\test\DatabaseName.mdb")
End Sub

Public Function StPasswordOfStDatabase(stDatabase As String) As String
    Dim hFile As Integer
    Dim ich As Integer
    Dim stBuffer As String
    Dim rgbytRaw() As Byte
    Dim rgbytPassword() As Byte
    Dim rgbytNoPassword() As Byte
    
    ' Create the byte array with the 20 bytes that are present when there
    ' is no database password
    rgbytNoPassword = ChrB(134) & ChrB(251) & ChrB(236) & ChrB(55) & ChrB(93) & _
                                ChrB(68) & ChrB(156) & ChrB(250) & ChrB(198) & ChrB(94) & _
                                ChrB(40) & ChrB(230) & ChrB(19) & ChrB(182) & ChrB(138) & _
                                ChrB(96) & ChrB(84) & ChrB(148) & ChrB(123) & ChrB(54)
                                
    ' Grab the 20 bytes from the real file whose password
    ' we are supposed to retrieve
    hFile = FreeFile
    Open stDatabase For Binary As #hFile
    Seek #hFile, 66 + 1
    rgbytRaw = InputB(20, #hFile)
    Close #hFile
    
    ' Enough prep, lets get the password now.
    ReDim rgbytPassword(0 To 19)
    For ich = 0 To 19
        rgbytPassword(ich) = rgbytRaw(ich) Xor rgbytNoPassword(ich)
    Next ich

    ' Add a trailing Null so one will always be found, even if the password is 20
    ' characters. Then grab up to the first null we find and return the password
    stBuffer = StrConv(rgbytPassword, vbUnicode) & vbNullChar
    StPasswordOfStDatabase = Left$(stBuffer, InStr(1, stBuffer, vbNullChar, vbBinaryCompare) - 1)
End Function
 
Password corruption

Hi Dennisk,

Thanks for your code.
I pasted it into another empty database.
The StPasswordOfStDatabase function worked and produces
ÅÏ‹tá‘WjÅN¯˜èQÐ^ÿ‹
as the password.
This password (not suprisingly) does not open the database.
I worked on this database Tue night and passed the link over the office local network to my work colleagues. After entering some data which is only to flag customers not receiving catalogues one of them said they could not get back into the database because it was asking for a password. I am sure no one has added a password to this database.

Is this possible corruption and if so how do you think I should prevent it?
Is there any way I can extract the data tables and/or queries, forms, reports and VB code from a database to which this has happened?

Regards,
Vince
 
I should point out that the code was for access 97, but i suspect the password is embedded at the same point in each .mdb.
Have you tried Jetcomp this is a MS utility to compress and repair files that the standard compact/repair cannot undertake.
 

Users who are viewing this thread

Back
Top Bottom