Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I detect what computers are accessing the program on a network

Status
Not open for further replies.

rresendez

Programmer
Mar 14, 2005
40
US
I am trying to detect what computers are accessing my program on a network. I need to limit the connections to a certain number of computers. Not how many connect at a anytime, but if there are supposed to only be 5 computers accesssing the program, I need to identify those 5 computers and not allow anymore computers to access it unless I update them to do so. I have looked at SYS(0) which returns the computer name for the computer running FoxPro. Will SYS(0) work when other computers attempt to run the EXE prg that I wrote? I want to have it get the computer name or whatever I can get and will allow 5 computers to be entered into a database and when 5 computers are in the database, no other computer will be able to be added to the database.

Any ideas would be appreciated.

Thanks,
Ramon
 
If you've found SYS(0) it's not too hard to track how many people have logged in.

Create a table named Login with a single field UserID C(20)

When someone logs in:
[tt]
Count To lnUsers For Not Deleted()
If lnUsers>=5
Forbid the login
Else
Insert Into Login Values(SYS(0))
Endif
[/tt]

When someone logs out:
[tt]
DELETE From Login Where UserID = SYS(0)
[/tt]

Geoff Franklin
 
Thanks Geoff,

Your reply seems to have up to 5 users on at a time, where I need 5 computers, because the users change all of the time (this is for a school of sort) when I need only to allow 5 computers on and they never get deleted. It is like a license for 5 computers and they cannot have 6 computers runing the program.

I do think I have solve it. I have the following:

comp_name=sys(0) && gets computer name
USE testacc && has no. of computers allowed
GOTO 1
acc_no=access_num &&access_num is the amount allowed

USE compnames && the names of the computers
LOCATE FOR compname=comp_name

IF FOUND()
CLEAR
ELSE
GO BOTTOM
c_count=RECNO()
IF c_count=acc_no && doesn't allow anymore than acc_no
CLEAR
@10,25 SAY "You do not have a license to access this program"
@15,25 SAY " "
WAIT
QUIT
ENDIF


APPEND BLANK && adds it if less than the 5 computers
REPLACE compname WITH comp_name
ENDIF
 
Ramon,

How about this:

- Create a table in advance. Add five records to it. (Doesn't matter what fields are in the records.)

- When someone logs on, loop through the table, trying to lock a record. If the lock fails, try the next one. When a lock finally succeeds, exit the loop.

- If you exited the loop without locking any records, then you have already hit the maximum user count. Kick the user out. Otherwise, let 'em in.

The advantage of this method is that it will still work reliably if the a user crashes out, without properly logging off. No matter how the user exits the app, his record will become unlocked.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top