Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / SQL Server / ADP / January 2006

Tip: Looking for answers? Try searching our database.

Get Login

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jose Perdigao - 25 Jan 2006 09:50 GMT
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
giorgio rancati - 25 Jan 2006 10:13 GMT
Hi Jose

try this

select system_user

----
SYSTEM_USER
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sysu
sr_3c8i.asp

----

bye
Signature

Giorgio Rancati
[Office Access MVP]

> 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
Jose Perdigao - 25 Jan 2006 13:57 GMT
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
>
[quoted text clipped - 14 lines]
> > Thanks
> > José Perdigão
giorgio rancati - 25 Jan 2006 17:30 GMT
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"

Signature

Giorgio Rancati
[Office Access MVP]

> Good afternoon
>
[quoted text clipped - 12 lines]
> I would like a function to get windows login.
> Thanks
Jose Perdigao - 25 Jan 2006 17:52 GMT
The authentication is windows NT Integrated security.
Thanks

Jose

> Hi Jose ,
>
[quoted text clipped - 21 lines]
> > I would like a function to get windows login.
> > Thanks
Jose Perdigao - 25 Jan 2006 17:55 GMT
Giorgio, it's correct, winthows authentication we get domain\login
Thanks

> Hi Jose ,
>
[quoted text clipped - 21 lines]
> > I would like a function to get windows login.
> > Thanks
Jose Perdigao - 26 Jan 2006 11:26 GMT
Giorgio,
Is it possibel to get the domain and login with two diferrent functions?
Thanks
Jose

> Hi Jose ,
>
[quoted text clipped - 21 lines]
> > I would like a function to get windows login.
> > Thanks
giorgio rancati - 26 Jan 2006 13:34 GMT
Hi Jose ,

you can modify your function

----
CREATE FUNCTION dbo.iLogin (@Type bit)
RETURNS varchar(30)
AS
-- @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 @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
Signature

Giorgio Rancati
[Office Access MVP]

> Giorgio,
> Is it possibel to get the domain and login with two diferrent functions?
> Thanks
> Jose
Jose Perdigao - 26 Jan 2006 15:16 GMT
His is a really what I want.
Works perfectly,
Thanks Giorgio

jose

> Hi Jose ,
>
[quoted text clipped - 34 lines]
> > Thanks
> > Jose
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.