User Name

J

Jose Perdigao

Good afternoon
I using the following function to get the login from Windows XP

ALTER FUNCTION dbo.iLogin ()
RETURNS varchar(30)
AS
BEGIN
/* Sql Server autentication mode */
IF CharIndex('\',system_user)=0
RETURN system_user
/* Windows Autentication mode */
RETURN SUBSTRING(system_user,CharIndex('\',system_user)+1,30)
ENDALTER FUNCTION dbo.iLogin ()
RETURNS varchar(30)
AS
BEGIN
/* Sql Server autentication mode */
IF CharIndex('\',system_user)=0
RETURN system_user
/* Windows Autentication mode */
RETURN SUBSTRING(system_user,CharIndex('\',system_user)+1,30)
END

I connect to sql server with - Use windows NT INtegrated security. The
function return the login of win XP, it works fine.

From remote connection, I can't connect using Windows NT INtegrated security
and then I must connect with SQL Server Authentication.
When I run the function, return the SQL Sever login and not Windows XP
login.

Question.

Is it possible create a funtion using Sql Server Autehntication connection
and return Windows XP login?

Any Suggestions?

Thanks,
José Perdigão
 
D

David Portas

Jose said:
Question.

Is it possible create a funtion using Sql Server Autehntication connection
and return Windows XP login?

Any Suggestions?

Thanks,
José Perdigão

I think not, since the login under which the user operates may not even
be in a domain that is known or trusted by the server. You could pass
in those credentials from client side.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
 
J

Jose Perdigao

Good Morning Graham,



In FE. I don't have problem, I can get the current user name (login) by VBA.

My problem is to create a function in SQL Server that returns the login and
use it as criteria in store procedures.



Thanks,

jose perdigao
 
S

Sylvain Lafontaine

When you are using SQL Server Authentication, the Windows XP login is never
transmitter over the wire and remains totally unknown to the SQL-Server.
This remains true even if both are located on the same local machine,
needless to say when they are not even part of the same domain as in your
case.

So unless you choose to transmit it yourself to the SQL-Server, you cannot
do what you have asked for in your original post.
 
J

Jose Perdigao

Thanks Sylvan.
I'll change my ideia and I will use as criteria, computrer name, I can get
it from SQL Server and put in SP.

Jose Perdigao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top