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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the login name of a ADO-connected user 3

Status
Not open for further replies.

davidchardonnet

Programmer
Mar 21, 2001
167
0
0
FR
Hello,

In my application, which connects to a database by a TADOConnection , I want to make a table which logs the connections of the users, with their login name, and other useful information. I don't know how I can get their login name? And as they log via ADO by NT authentification to a sql server database, I wonder if it's possible...

Do you know how to do it?

Thank You

David
 
We have an Oracle database with a function in the SYS schema called LOGIN_USER(), which essentially makes a call
to: dbms_standard.login_user. I use these methods to display information in a status panel in my apps.

As for other database, I can't help you!
 
Well I use a login form where I have to specify the user name and the password in Interbase, the username I store in xUser to display the connected user in the statusbar.
Somewhere in the application you have supply the user and the password, that is where you can catch it. The NT user account doesn't have by default access to the SQL-server.

example:
function GetLoginParams(ALoginParams: TStrings): Boolean;
var
LoginForm: TLoginFrm;
begin
Result := False;
LoginForm := TLoginFrm.Create(Application);
try
if LoginForm.ShowModal = mrOk then
begin
ALoginParams.Values['USER NAME'] := LoginForm.edtUsername.Text;
ALoginParams.Values['PASSWORD'] := LoginForm.edtPassWord.Text;
xUser:= LoginForm.edtUsername.Text;
Result := True;
end;
finally
LoginForm.Free;
end;
end; Steven van Els
SAvanEls@cq-link.sr
 
Since the users are logging on using NT authentication, why not just fetch their Windows username.

Example:

var
sUserName : Pchar;
iLen : Cardinal;
begin
Getmem(sUserName,30);
iLen := 30;
GetUserName(Pchar(sUserName),iLen);
Result := sUserName;
FreeMem(sUserName);
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top