cancel
Showing results for 
Search instead for 
Did you mean: 

User logged name only usin SQL query? without DIAPI

Former Member
0 Kudos

Hi all ,

Exist a SQL query to obtain the logged user without using DIAPI programing? Only in an SQL query?.

I think that one cannot. Am I in the certain thing?

Thank you all again.

Regards.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thak you very much for help me.

It´s a pleasure to post in this forum.

Best regards.

Former Member
0 Kudos

Petr what is FS?

Thank you again.

Regards.

Former Member
0 Kudos

formatted search

former_member201110
Active Contributor
0 Kudos

Hi,

You can use the following SQL statement to return the login name of the user who owns the current connection:


select SUSER_SNAME()

If you are using Windows Authentication to connect the SBO client to the database then this will return the Windows login. If you are using SQL Authentication then it will return the SQL account that is being used. Whether or not you will be able to match this login to the SBO login id will depend on how your system is set up. Ideally, you'd be using Windows Authentication and your SBO logins would match your Windows login, in which case, there's no mapping required. Otherwise you may need to set up a mapping table so you can cross reference the SQL login to get the SBO login. If you are using SQL Authentication to connect the SBO clients and you are using the same sql login account for each workstation, you won't be able to use the above solution to work out the SBO login.

Kind Regards,

Owen

Former Member
0 Kudos

Thank you for response to all,

If i put "SELECT U_NAME FROM OUSR WHERE INTERNAL_K = $[user]

" i give an error.

If i put "select $[user]" i obtain always 0,00.

And using last login, i cannot affirm that the last logged user is my loggin user.

$[user] is a global variable that have a user id logged?

Thank you again.

Former Member
0 Kudos

You can simply get it from ocompany.UserName (without DI API). The INTERNAL_K = $user works only for FS and not for recordset.

Nussi
Active Contributor
0 Kudos

Petr,

you need to use

oCompany.Connect

before you can access the UserName.

and that's DIAPI

lg David

Former Member
0 Kudos

You are true, sorry

Maybe some solution, which will be not working for terminal users in case of non trust connection to sql server - just an idea - in login to SAP, is called transaction notification with update for objecttype = 12 (Users) - updates the last login column in OUSR table. Inside this stored procedure you are able to find out the hostname of computer and login name to sql. You will stored in this sp somewhere that user 123 have hostname abc and is logged with trusted as nt login def. Then when you will be able find out, who is logged based on this datas. Just idea...

Former Member
0 Kudos

Or a formatted search with the following query :



SELECT U_NAME FROM OUSR WHERE INTERNAL_K = $[user]

Binita

Former Member
0 Kudos

Hi,

Check OUSR and LastLogin

Hope it helps,

Vasu Natari