Re: apiGetUserName Lib "advapi32.dll"




I've just tried what Doug suggested and it worked fine.

I suspect you missed the phrase "pass-through".

You create a pass-through query so that the SQL is executed on the SQL
Server not by Access.



--

Terry Kreft


"Me" <Me@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CD81FE4C-5540-44CF-9B4F-EA48A51E0A12@xxxxxxxxxxxxxxxx
Douglas,

Here is what I tried -
When I run the following query in 'Query Analyzer', I get the desired
result -
select user, current_user, session_user,system_user


However, when I run the same in Acces Database I get error since it
doesn't
recognize from where its supposed to retrieve the data.


So I linked the sysusers table and modified the query in Access as
follows -

SELECT name, *
FROM sysusers
WHERE name=session_user;

It doesn't recognize session_user and it asks for session_user.

Do you have other suggestions?

Thank you,
-Me



"Douglas J. Steele" wrote:

You need to get that from SQL Server, not from WIndows.

You can create a pass-through query that retrieves the name from SQL
Server.
Unfortunately, I can never remember which keyword you need to use: it's
one
of USER_NAME, CURRENT_USER, SESSION_USER or SYSTEM_USER.

Go into SQL Server and run the following:

SELECT USER_NAME(), CURRENT_USER, SESSION_USER, SYSTEM_USER

Which of those 4 is what you're looking for?


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Me" <Me@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:539CD436-C0F1-4881-AE63-8900CE36EF4C@xxxxxxxxxxxxxxxx
I have a function apiGetUserName that uses - Lib "advapi32.dll"
to get me the username.

But this gets me the windows username with which I am logged on to the
computer.

I want to get the username with which I am logged on to SQL server
database.
Please note its not the access database login, but sql server login.

Thank you very much in advance,
-Me






.



Relevant Pages

  • RE: How to evade white spaces in a SQL injection
    ... The 2nd one is more likely since they're proably adding the ' character to ... So you'd enter '+1-- as the username. ... +1 tells sql to add 1 to a character field, which it can't do, the -- ... comments out the remainder of the query so it doesn't get parsed. ...
    (Pen-Test)
  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)
  • Append/copy calling a module switches data
    ... I've taken the SQL from the previous posting (graciously ... When I run the query just by itself it does create a copy and put "dlongton" ... leaving the UserName in the original record as it was ... CreatedBy) in the original record and the newly copied record...it's driving ...
    (microsoft.public.access.queries)
  • Re: Populating a list -- table structure?
    ... I had made a report already and figured out about adding the ... your responce below, but thanks to your help with SQL, I was able to get the ... It takes a summary from a select query and gives the ... KitID, long integer ...
    (microsoft.public.access.forms)
  • How do I do Paging through a large dataset via Stored Procedures
    ... Paging by dynamically altering the SQL Query ... Create stored procedures ... SELECT * FROM STUDENTS ...
    (microsoft.public.dotnet.framework.adonet)