Solved

find computer/user using a database file

Posted on 2002-03-26
12
140 Views
Last Modified: 2010-04-04
Hi,

In a multi user environment is it possible to identify the computer or user that is using a database file. IE I have a multi user system where at times there is a need to open the files exclusively (eg rebuild indexes), but when trying to open the files exclusively I can't because someone else is in the system - How can I identify who this is so that I can locate this user and ask them to exit the system.

Thanks
Clyde
0
Comment
Question by:clyde99
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6898378
I guess it depends on the type of database you're using.  MS SQL for instance only uses one file to hold all the tables, so the only way you'll be able to find out who's accessing them is to query the database system.

If you're accessing the database through an ODBC driver, then that may make it even more difficult that accessing it directly as the ODBC driver could contain the login details for one account and therefore be not user specific.

My guess would be, find out what database you are using, and then see if there's any APIs for it floating around.  If there are, you're chances of success are a lot greater.

Stu
0
 

Author Comment

by:clyde99
ID: 6898510
Thanks stu,

I am using the BDE with dbase tables - Any way you know of getting this information from the BDE?

Thanks
Clyde
0
 
LVL 1

Expert Comment

by:Summa
ID: 6898645
Hi,

as far as I know this is only possible with
Paradox .db files. But I'm not sure...

Maybe this can help you.


a function for paradox-tables.
==============================================

uses BDE, ....;

....

procedure GetTableUsers(ATable: TTable; AStrings: TStrings);
var
  TmpCursor: hdbicur;
  LockInfo: LOCKDesc;
  Status: dbiResult;
begin
  Check(DbiOpenLockList(aTable.Handle, True, True, TmpCursor));
  Check(DbiSetToBegin(TmpCursor));
  Repeat
    Status := DbiGetNextRecord(TmpCursor, dbiNOLOCK, @LockInfo, Nil);
    AStrings.Add(LockInfo.szUserName);
  Until (Status <> DBIERR_NONE);
  Check(DbiCloseCursor(TmpCursor));
  Check(DbiCloseCursor(TmpCursor));
end;
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6898811
Hi Clyde,

I'm fairly sure you'll find Summa's suggestion will work with dBase tables.  I guess there is only one way to know for sure :)

Summa.  Can I ask where you obtained that code?  I quite often need a few low level DB routines and if it's from a library, I'd be interested to know where to get it.

Cheers folks,

Stu
0
 

Author Comment

by:clyde99
ID: 6899036
Hi Summa,

Thanks for the code snippet.

Unfortunately when I tried with a dbase file, the BDE came up with the exception error "Project1.exe raised exception class EDBEngineError with message 'Capability not supported'"

So it looks like this will not work with BDE and Dbase files.

Looks like I may have come to a dead end here unless anyone else has some other ideas?

Clyde
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6900479
Hi Clyde,

I had a thought last night.  Are the tables being served from an NT/2000/XP box?  If so, there is an administration tool which allows you to see who has what files open.  Perhaps there is a way you can find some info on what APIs that application uses and implement them in your program?  There was a big write up in The Delphi Magazine a few months ago about the Active Directory.  I believe there is ways of finding this sort of info out use the Active Directory.  I don't have the mag with me, but will check tonight and let you know.

Stu
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:clyde99
ID: 6901029
Hi Stu,

Yes, the Dbase files are on a Windows 2000 Server box(but I am not using active directory). However, I have used the admin tool that you refer to and If I could get access to that information via some API then that would solve my problem.

Thanks
Clyde
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6901048
Hi Clyde,

Does the admin tool show who's logged in, or is it just showing a generic (say SYSTEM) account??

I'll have a look for the info on Active Directories tonight and post you anything relevant.  You can actually go to their website and download previous issues cover disks, so if I give you the issue number, you'll be able to get the source code for it.

Stu
0
 

Author Comment

by:clyde99
ID: 6901140
Hi Stu,

The admin tool I refer to is "Computer Management" (from the control panel). When you drill down in this tool from "System Tools", then "Shared Folders", Through a combination of "Shares" and "Open Files" is all the information I need.

Clyde
0
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 100 total points
ID: 6901350
Hi Clyde,

No worries, mate.  Let's see if that article can help you or not.  I'll be home from work in about 4 hours, so I'll post something as soon as I locate it.

Stu
0
 
LVL 1

Expert Comment

by:Summa
ID: 6902127
for STU:
==========

>Summa.  Can I ask where you obtained that code?  I quite >often need a few low level DB routines and
>if it's from a library, I'd be interested to know where >to get it.

I found that snippet somewhere, but can't remember
the URL. Such BDE routines are very hard to find.
Look at the BDE-Help, there are some samples in it.


0
 

Expert Comment

by:CleanupPing
ID: 9343213
clyde99:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now