ADS: sp_mgGetUserTables() with same user name

This forum is for eXpress++ general support.
Message
Author
User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

ADS: sp_mgGetUserTables() with same user name

#1 Post by Tom »

Hi, there.

In a topology that runs on (among other things) a terminal server, all users who connect to the ADS have the same username under most installation circumstances. If you retrieve further information about this with sp_mgGetConnectedUsers(), you will get, for example, the actual user name with which you logged in to Windows, as well as the IP and a few other pieces of information. Unfortunately, at least for me, the "ConnNumber" is always and in all cases 0 (zero), and unfortunately that is the only other way to find out who keeps which tables open via sp_mgGetUserTables(). So: I have "TERMINAL SERVER USER" three times as an ADS user, and all three have connection number 0. I see three different connections, but via sp_mgGetUserTables() with "TERMINAL SERVER USER" I always get the same tables - namely the ones that all three users have opened. Alternatively with the connection number (0) it is the same.

You can test this with the ADSMGT-tool Roger provided.

Any ideas?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: ADS: sp_mgGetUserTables() with same user name

#2 Post by rdonnay »

I will run my AdsMgt program on the terminal server tomorrow morning after I can make several RDP connections.

Most of our users are connecting from workstations on a LAN.
The eXpress train is coming - and it has more cars.

k-insis
Posts: 100
Joined: Fri Jan 28, 2011 4:07 am

Re: ADS: sp_mgGetUserTables() with same user name

#3 Post by k-insis »

To track users who have open files eg. program running so you can kick it out of exe for maintenance?

How about each user has single, after that user named table? Like 'con_sepplG.dbf' , 'conn_betinaM.dbf', etc and all are opened shared+RO all the time in separate thread. So you might check for open tables in ads management tool.

Tom wrote: Mon Nov 13, 2023 8:49 am Hi, there.

In a topology that runs on (among other things) a terminal server, all users who connect to the ADS have the same username under most installation circumstances. If you retrieve further information about this with sp_mgGetConnectedUsers(), you will get, for example, the actual user name with which you logged in to Windows, as well as the IP and a few other pieces of information. Unfortunately, at least for me, the "ConnNumber" is always and in all cases 0 (zero), and unfortunately that is the only other way to find out who keeps which tables open via sp_mgGetUserTables(). So: I have "TERMINAL SERVER USER" three times as an ADS user, and all three have connection number 0. I see three different connections, but via sp_mgGetUserTables() with "TERMINAL SERVER USER" I always get the same tables - namely the ones that all three users have opened. Alternatively with the connection number (0) it is the same.

You can test this with the ADSMGT-tool Roger provided.

Any ideas?

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: ADS: sp_mgGetUserTables() with same user name

#4 Post by Tom »

To track users who have open files eg. program running so you can kick it out of exe for maintenance?
To track users who have special files open. I'm talking about a situation with 200+ users in a mixed environment, about half of them using a TS with the same user name on that TS (which is standard on a TS - the name of the computer). All the guys accessing via LAN ("classical") are no problem. I can find the OSUserLoginNames of those users to find out from which workstation they connected, but I can only use the UserName to get the information of opened tables by a user, so I get all tables open used by (all) the TS user(s), because those user names are not unique. I need to find a way to match open tables with the OS login names.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: ADS: sp_mgGetUserTables() with same user name

#5 Post by Tom »

What I need is a way to find the tables used by an ADS user with a special "TSAddress". This information is unique even on a Terminal Server.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: ADS: sp_mgGetUserTables() with same user name

#6 Post by Tom »

Found a way, Marcus Herz from the german forum helped me.
If I retrieve all user tables open for a user name (which is the computer name), I can walk through the result list and find out using "sp_mgGetTableUsers(<cTable>)", which TSAddress or OSLoginUserName is attached to every open table. This gives me the information I need.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

k-insis
Posts: 100
Joined: Fri Jan 28, 2011 4:07 am

Re: ADS: sp_mgGetUserTables() with same user name

#7 Post by k-insis »

Great!

Thx for sharing info. Might be handy.
Tom wrote: Tue Nov 14, 2023 1:53 am Found a way, Marcus Herz from the german forum helped me.
If I retrieve all user tables open for a user name (which is the computer name), I can walk through the result list and find out using "sp_mgGetTableUsers(<cTable>)", which TSAddress or OSLoginUserName is attached to every open table. This gives me the information I need.

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: ADS: sp_mgGetUserTables() with same user name

#8 Post by Tom »

To mention Marcus again:

He pointed out to me that the "Connection number" only worked in the context of NetWare and has been de-supported for quite a while. ;)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: ADS: sp_mgGetUserTables() with same user name

#9 Post by Tom »

Addition: Using those stored procedures again and again may lead to ADS Error 7216, which means the number of SQL-statements for that connection is exceeded. sp_SetStatementLimit(0) solves that problem.

Edit: Correcting a misbehaviour solves the problem aswell.

I took the functions from ADSMGT.PRG, which use the SQL command translated into DC_AdsSqlStatement(). It is needed to close the statement after finishing the function, like this:

Code: Select all

STATIC FUNCTION LoadTableUsers(oSession,cTable)
LOCAL cSql, cAlias := 'Tables', aObjects := {}, oStatement

TEXT INTO cSql WRAP
SELECT * FROM
(
  EXECUTE PROCEDURE sp_mgGetTableUsers('TABLE')
) anyalias
ENDTEXT

cSql := StrTran(cSql,"TABLE",AllTrim(cTable))

SQL cSql INTO OBJECTS aObjects INTO CURSOR cAlias VIA oSession TO oStatement

dbCloseArea()
oStatement:Close() // <-- don't forget, otherwise open workareas will increase and the number of open statements aswell
RETURN aObjects
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: ADS: sp_mgGetUserTables() with same user name

#10 Post by rdonnay »

We have 3 or 4 users who connect via RDP and VPN occasionally to 2 different user accounts on the server.

This screen shows what info we have on those connections.
The username is W2016SVR on each connection, but they have different TSAddress which is the VPN address..
adsmgt.JPG
adsmgt.JPG (213.6 KiB) Viewed 1860 times
The eXpress train is coming - and it has more cars.

Post Reply