I'm trying to do what seems like a simple project, and find out who has an Access Database open. The basic code is below, and it works fine for me, (I'm a domain admin) but when a normal user tries to run it, they don't have the rights required.

Is there a way to change the GetObject("WinNT://....) statement to log in with other credentials, or, barring that, a better way to do this?

Thanks!

Private Sub Command1_Click()
On Error Resume Next
Dim fso
Dim FindPos
Dim strInput
Dim strWho


ListResults.Clear

strInput = Text1.Text
TextServer = Text2.Text

'  Bind to a file service operations object on “servername" in the local domain.
Set fso = GetObject("WinNT://" & TextServer & "/LanmanServer")

' Enumerate resources
If (IsEmpty(fso) = False) Then
    For Each resource In fso.resources
        If (Not resource.user = "") And (Not Right(resource.user, 1) = "$") Then
            FindPos = InStr(1, resource.Path, strInput, 1)

                If (FindPos <> 0) Then
                    strWho = resource.user & "=" & resource.Path
                    ListResults.AddItem (strWho)
                End If
        End If

    Next
End If
End Sub

I take it the *.MDB is on a share as the back end to an existing system. Can the system itself be modified? Should be simple enough for programmer to add table and a quick loged in loged out switch in table. Then table could be queried. Just a thought...

BTW [ / code]


Good Luck

I take it the *.MDB is on a share as the back end to an existing system. Can the system itself be modified? Should be simple enough for programmer to add table and a quick loged in loged out switch in table. Then table could be queried. Just a thought...

BTW [ / code]


Good Luck

Thanks for the suggestion! The database is actually just a stand-alone Access database, and we have many of them. I'm trying to come up with a utility that will tell our users, or at least our helpdesk staff, who has it open.
For that matter, I'd like to have it work with other files as well, such as spreadsheets or Word documents.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.