Highlighted
Absent Member.
Absent Member.
610 views

[archive] license manager or # of users in system

[Migrated content. Thread originally posted on 01 August 2005]

Does anyone have a license manager or a way of tracking the number of users using the system? The number of licenses for AcuCobol may be different from the number they purchase from us. We need to figure out a way to count the number of users using cobol. Environment may be windows server, or unix server, runtime is windows 6.2.

Keeping a log and adding and subtracting as people log on and off will not work because if they disconnect improperly, the subtract will never occur and we would have to reset the file count.

In FoxPro, you can open a file exclusively and it it passes the exclusive open then resets the count, close it and open it again not exclusively. All other users have it open too as they log on and the count is incremented by one. When they log off the count is subtracted. The exclusive open for the first user on the system alway resets the count back to 0. That works there.

I am trying to figure out how to do something like that in Cobol so occassionaly, the count will be reset back to zero when there is no one on the system or back to one when the first user logs on.

Perhaps you have a better method to handle tracking the number users. Any solutions or ideas would be greatly appreciated.

Patty
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] license manager or # of users in system

Allow me to point out the fact that the foxpro solution will be as prone to error conditions due to improper disconnection as would the logging in a file.

Nevertheless, since you mention FoxPro, I assume you are restricting yourself to Windows, thus, what you can use is the server api function NetFileEnum in the netapi32.dll.

For an example of how to use this function, see the EnumOpenFiles from the Advanced Windows training.

Note however, this ain't gonna be an easy path, but the benefits are obvious:
o It can't be cheated
o It resets when the server boots
o You can programmatically release a count
o You can even send a message to the user from the server, e.g. it is possible to maintain the count from a server application.

Because should a counting mechanism should be a server app, otherwise all users would have to have administrator or account manager privileges on the server. This is of course a catch with it all.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] license manager or # of users in system

This can be done using an Acucobol indexed file - that's what I have done for several years and it works well.

I use an indexed file with a sequence number as the key. When the software starts, it calls a program with IS RESDIENT in it's PROGRAM-ID so it remains in memory throughout the session.

It opens an indexed file which is in a known location so all users see the same file.

It then executes a loop from 1 through the license limit, using the counter as a key into the indexed file. For each cycle through the loop, it first attempts to read that record with lock. (key = 1, key = 2, key = 3, etc.)

If it is locked, it cycles through the loop again (because another user has that slot/license).

If it is not locked, it read that record with lock (to hold it locked), sets a flag and exits the loop. If the record does not exist, it writes that record then immediately reads it with lock to keep it locked, sets a flag, and then it exits the loop.

If it reaches the end of the loop without having set the flag, then the license limit has been exceeded and the user is denied access.

If the flag is set, the user obtained a slot (license) and can continue.

The program exits (returning the allowed/denied status to the caller). If the user obtained a slot, since the program is resident, their slot in the license file will remain locked for the entire session.

However, since it is depending on locks to determine slot usage and the operating system manages the locks, if the runtime aborts, the operating system releases the lock automatically, not the program. You don't have to worry about deleting or freeing records when your system exits because the OS automatically frees the lock when the process ends.

I've used this scheme on both Unix and Windows for at least 15 years and have never once had a problem with an inaccurate license count.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] license manager or # of users in system

JoeD. Thanks. This is exactly what I was looking for. Can you email me your program that you call and/or any copybooks.

Thanks so much for your time. pstepp@comcast.net

Patty
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.