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?
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
Edited 3 Years Ago by mike_2000_17: Fixed formatting