|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Good morning, To get computer name I use HOST_NAME() Is it possible to get the windows login through a sp or udf?
Thanks José Perdigão
|
|
Hi Jose
try this
select system_user
---- SYSTEM_USER http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sysusr_3c8i.asp ----
bye -- Giorgio Rancati [Office Access MVP]
"Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel messaggio news:7F2B6847-59A3-4B18-8487-5C74E29F4E2A[ at ]microsoft.com...
[Quoted Text] > Good morning, > To get computer name I use HOST_NAME() > Is it possible to get the windows login through a sp or udf? > > Thanks > José Perdigão
|
|
Good afternoon
I did the folowinf function: ALTER FUNCTION dbo.iLogin () RETURNS varchar(10) AS BEGIN RETURN system_user END
The return value is SQL server user name, I mean, if I logg the computer with diferent windows user, the result is the same.
I see, system_user is the same SUSER_SNAME(), isn't it? I would like a function to get windows login. Thanks
"giorgio rancati" wrote:
[Quoted Text] > Hi Jose > > try this > > select system_user > > ---- > SYSTEM_USER > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sysusr_3c8i.asp> ---- > > bye > -- > Giorgio Rancati > [Office Access MVP] > > "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel > messaggio news:7F2B6847-59A3-4B18-8487-5C74E29F4E2A[ at ]microsoft.com... > > Good morning, > > To get computer name I use HOST_NAME() > > Is it possible to get the windows login through a sp or udf? > > > > Thanks > > José Perdigão > > >
|
|
Hi Jose ,
What's your Authentication mode ?
In "Windows Authentication mode" the system_user returns the DOMAIN\user_login_name. Sql Server can't know the Windows User name if the Authentication is "SQL Server Authentication"
-- Giorgio Rancati [Office Access MVP]
"Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel messaggio news:7947BD5A-9CF6-4093-91A7-FF5DCA221748[ at ]microsoft.com...
[Quoted Text] > Good afternoon > > I did the folowinf function: > ALTER FUNCTION dbo.iLogin () > RETURNS varchar(10) > AS > BEGIN > RETURN system_user > END > > The return value is SQL server user name, I mean, if I logg the computer > with diferent windows user, the result is the same. > > I see, system_user is the same SUSER_SNAME(), isn't it? > I would like a function to get windows login. > Thanks >
|
|
The authentication is windows NT Integrated security. Thanks
Jose
"giorgio rancati" wrote:
[Quoted Text] > Hi Jose , > > What's your Authentication mode ? > > In "Windows Authentication mode" the system_user returns the > DOMAIN\user_login_name. > Sql Server can't know the Windows User name if the Authentication is "SQL > Server Authentication" > > -- > Giorgio Rancati > [Office Access MVP] > > "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel > messaggio news:7947BD5A-9CF6-4093-91A7-FF5DCA221748[ at ]microsoft.com... > > Good afternoon > > > > I did the folowinf function: > > ALTER FUNCTION dbo.iLogin () > > RETURNS varchar(10) > > AS > > BEGIN > > RETURN system_user > > END > > > > The return value is SQL server user name, I mean, if I logg the computer > > with diferent windows user, the result is the same. > > > > I see, system_user is the same SUSER_SNAME(), isn't it? > > I would like a function to get windows login. > > Thanks > > > > >
|
|
Giorgio, it's correct, winthows authentication we get domain\login Thanks
"giorgio rancati" wrote:
[Quoted Text] > Hi Jose , > > What's your Authentication mode ? > > In "Windows Authentication mode" the system_user returns the > DOMAIN\user_login_name. > Sql Server can't know the Windows User name if the Authentication is "SQL > Server Authentication" > > -- > Giorgio Rancati > [Office Access MVP] > > "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel > messaggio news:7947BD5A-9CF6-4093-91A7-FF5DCA221748[ at ]microsoft.com... > > Good afternoon > > > > I did the folowinf function: > > ALTER FUNCTION dbo.iLogin () > > RETURNS varchar(10) > > AS > > BEGIN > > RETURN system_user > > END > > > > The return value is SQL server user name, I mean, if I logg the computer > > with diferent windows user, the result is the same. > > > > I see, system_user is the same SUSER_SNAME(), isn't it? > > I would like a function to get windows login. > > Thanks > > > > >
|
|
Giorgio, Is it possibel to get the domain and login with two diferrent functions? Thanks Jose
"giorgio rancati" wrote:
[Quoted Text] > Hi Jose , > > What's your Authentication mode ? > > In "Windows Authentication mode" the system_user returns the > DOMAIN\user_login_name. > Sql Server can't know the Windows User name if the Authentication is "SQL > Server Authentication" > > -- > Giorgio Rancati > [Office Access MVP] > > "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel > messaggio news:7947BD5A-9CF6-4093-91A7-FF5DCA221748[ at ]microsoft.com... > > Good afternoon > > > > I did the folowinf function: > > ALTER FUNCTION dbo.iLogin () > > RETURNS varchar(10) > > AS > > BEGIN > > RETURN system_user > > END > > > > The return value is SQL server user name, I mean, if I logg the computer > > with diferent windows user, the result is the same. > > > > I see, system_user is the same SUSER_SNAME(), isn't it? > > I would like a function to get windows login. > > Thanks > > > > >
|
|
Hi Jose ,
you can modify your function
---- CREATE FUNCTION dbo.iLogin ([ at ]Type bit) RETURNS varchar(30) AS -- [ at ]Type 0 returns Domain -- 1 returns user BEGIN
/* Sql Server autentication mode */ IF CharIndex('\',system_user)=0 RETURN system_user
/* Windows Autentication mode */
--Domain IF [ at ]Type=0 RETURN LEFT(system_user,CharIndex('\',system_user)-1)
--User RETURN SUBSTRING(system_user,CharIndex('\',system_user)+1,30)
END ----
-- Get domain name Select dbo.iLogin(0) -- Get Login name Select dbo.iLogin(1)
bye -- Giorgio Rancati [Office Access MVP]
"Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel messaggio news:8A25FC66-3979-4247-AC20-A1C57B3737F1[ at ]microsoft.com...
[Quoted Text] > Giorgio, > Is it possibel to get the domain and login with two diferrent functions? > Thanks > Jose
|
|
His is a really what I want. Works perfectly, Thanks Giorgio
jose
"giorgio rancati" wrote:
[Quoted Text] > Hi Jose , > > you can modify your function > > ---- > CREATE FUNCTION dbo.iLogin ([ at ]Type bit) > RETURNS varchar(30) > AS > -- [ at ]Type 0 returns Domain > -- 1 returns user > BEGIN > > /* Sql Server autentication mode */ > IF CharIndex('\',system_user)=0 > RETURN system_user > > /* Windows Autentication mode */ > > --Domain > IF [ at ]Type=0 > RETURN LEFT(system_user,CharIndex('\',system_user)-1) > > --User > RETURN SUBSTRING(system_user,CharIndex('\',system_user)+1,30) > > END > ---- > > -- Get domain name > Select dbo.iLogin(0) > -- Get Login name > Select dbo.iLogin(1) > > bye > -- > Giorgio Rancati > [Office Access MVP] > > "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> ha scritto nel > messaggio news:8A25FC66-3979-4247-AC20-A1C57B3737F1[ at ]microsoft.com... > > Giorgio, > > Is it possibel to get the domain and login with two diferrent functions? > > Thanks > > Jose > > >
|
|
hello "Jose Perdigao" <JosePerdigao[ at ]discussions.microsoft.com> wrote in message news:7F2B6847-59A3-4B18-8487-5C74E29F4E2A[ at ]microsoft.com...
[Quoted Text] > Good morning, > To get computer name I use HOST_NAME() > Is it possible to get the windows login through a sp or udf? > > Thanks > José Perdigão
|
|
|