Group:  Microsoft Access » microsoft.public.access.adp.sqlserver
Thread: Get Login

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Get Login
Jose Perdigao 25.01.2006 09:50:05
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
Re: Get Login
"giorgio rancati" <giorgio_No_Spalmer_rancati[ at ]tiscali.it> 25.01.2006 10:15:40
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


Re: Get Login
Jose Perdigao 25.01.2006 13:57:04
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
>
>
>
Re: Get Login
"giorgio rancati" <giorgio_No_Spalmer_rancati[ at ]tiscali.it> 25.01.2006 17:30:53
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
>


Re: Get Login
Jose Perdigao 25.01.2006 17:52:03

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
> >
>
>
>
Re: Get Login
Jose Perdigao 25.01.2006 17:55:03
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
> >
>
>
>
Re: Get Login
Jose Perdigao 26.01.2006 11:26:02
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
> >
>
>
>
Re: Get Login
"giorgio rancati" <giorgio_No_Spalmer_rancati[ at ]tiscali.it> 26.01.2006 13:34:31
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


Re: Get Login
Jose Perdigao 26.01.2006 15:16:02
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
>
>
>
Re: Get Login
"asal" <zahra_m63[ at ]microsaft.com> 30.01.2007 10:02:09
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


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net