Get the User Name for a login user

Hi Guys,

How can I get the current loged in UserName in windows in MSSQL?

The problem is:

  • Users login into their PC (Windows Login)
  • Enter a URL of the intranet application
  • They would then be able to access the web base application (Intranet)
  • The web application has a string connection to make a connection to the database
  • I want to have a Trigger for my "products" table so if the table is modified (Insert/Update)  all those changes be entered in "products_Audit" table
  • Now on "products_Audit" table I have a field "ChangedBy" where I want to store the windows loged in User Name (SYSTEM_USER just return the Username for the SQL connection that the web application use)

I would really appreciate all your help and suggestions.

Regards,
Mehdi


Mehdi Entezary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
0
Mehdi6002
4/13/2007 12:02:37 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
1039 Views

Similar Articles

[PageSpeed] 43

Hello,

In case of IntraNet where directory security does not allow anonymous users, then you can retrieve domain user information.

dim user as string = Request.ServerVariables("LOGON_USER")

and pass this variable for your database action query.

Big Smile

0
busyweb
4/13/2007 1:38:53 PM
Reply:

Similar Artilces:

Getting error "Login failed for user ''. The user is not associated with a trusted SQL Server connection" on trying to authenticate a user
Hi, I created aspnetdb on Sql Server 2005 and modified my web.config LocalSqlServer connection string to connect to the Sql Server instead of mdf file on Sql Server. When i click Log In button on my login control i am getting the error "Login failed for user ''. The user is not associated with a trusted SQL Server connection" But when i bind a radio button list or any control to select from aspnet_users or roles table data is displayed fine without any login errors (i am using aspnetdbConnectionString given below for binding data). Why is it happening only when i authenticate but...

could you explain me what is schema in sql2005? and why when i restore my data base my user have no login name so i have to create new user and login name?
hi, could you explain me what is schema in sql2005?  and why when i restore my database my user have no login name so i have to create new user and login name? thanks alot Hey, A schema is a logical grouping of objects; it's a way to separate tables into different logical groups, as one way of looking at it.  You can assign rights to the schema.  Schemas existed in 2000 in a sense, that everything belonged to the dbo schema (or your account name's schema), but it's not like it is in 2005.  You can make tables/procs belong to a schema, and then you have t...

Cannot open user default database. Login failed. Login failed for user 'DOMAIN\User'. (.Net SqlClient Data Provider)
Hi when i try and open a database in sql server management studio i get the error "Cannot open user default database. Login failed. Login failed for user 'DOMAIN\User'. (.Net SqlClient Data Provider)", what can i do to rectify this, i have googled around and still havent found no answers. Which authentication mode is your Sql Server configured - MixedMode, Windows Authentication or Sql Server Authentication? Please refer to http://msdn2.microsoft.com/en-us/library/ms366351.aspx and http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx    Ple...

Can't get ntlm user login name, always returns user aspnet
Hi all, I've tried environment as well as windowsIdentity.getcurrent.name and both return the same user:ASPNET. I have set the website to use NTLM and use a completely different login (bob\bob) and it always says user name is aspnet.  I am thinking that since it's an aspx page that there is some impersination or the aspx server side is using that accnt for running the pages.  How would I get the acutal NTLM user name? Any ideas would be greatly appreciated.   Thanks Sounds like you need to do a "authentication = Windows" and "impersonate = true" in your web.config file....

In debug mode I get Login failed for user ''. The user is not associated with a trusted SQL Server connection.
The error msg only appears when I try and debug. When using the site normally there is no problem?? Hello,     The reference below is the solution of your problem.     The user is not associated with a trusted SQL Server connectionPlease give us feedback no matter whether you get your answer.Please "mark as answer" if it's useful for youSincerely,Jerome...

What has to happen after login before Page.User.Identity.Name contains the user name?
I am using Membership Services in my new ASP.NET 3.5 app. I want to redirect the user to a page where he can enter various personal details if he has not yet done this. I put some VB.NET code in the LoggedIn event for my Login control that depends on the availability of the current user name in Page.User.Identity.Name but this reference is Nothing at this stage in the process. Page.User.Identity.Name works fine on other pages. When exactly is Page.User.Identity.Name loaded with the name of the current user?David   The authentication process hapen like this... 1-User request a secur...

Directing users to different pages after login depending on login user name
how can i direct my application users to different pages depending on the users login user name. Iam thinking that it would make sense if  users who enter data are directed to a data entry page after logging in and users who run reports are directed to a report page though both users will have to sign in from one login page. Iam open to any idea as long as it acompolishes this task.--------------------------------------------------No Project Too Eazy.--------------------------------------------------...

Can not get user name from HttpContext.Current.User.Identity.Name
Hi All; I have tried to use HttpContext.Current.User.Identity.Name to get window user account. However, from debugger, for a long time ago I saw my window user name. But now, I did not see my window user name (from debugger) with the same code and same function call. Please help. Was I doing something wrong? Or any special settings on web.config/machine.config or project to make it work??? I'm stuck Thanks a lot well, you have to have windows integrated authentiction enabled in IIS, IIRC.RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unre...

get user name by user id
hi i send the user ID to a page and there i wanna find the user name. can you please let me know how to find a user name by user id? tanks  Are you using Active Directory? If so check out this tutorialCommunity Coder Hi you can pass the Guid USerId to Membership.GetUser method,MembershipUser usr = Membership.GetUser(UserIDAsGuid); string userName = usr.UserName; // to get the current logged in username , just use HttpContext.Current.User.Identity.Name;    Regards,Anas Ghanem.Note:Please Don't hesitate to click "Report Abuse" link if you noticed som...

Login failed for user 'Bachelorplace'. The user is not associated with a trusted SQL Server connection. (.Net SqlClient Data Provider)
please tellme how to resolve this error, i m using server studio management tool. and trying to connect using sql server authentication. my pc is over a domain.   Login failed for user 'Bachelorplace'. The user is not associated with a trusted SQL Server connection. (.Net SqlClient Data Provider)  check whether that sql server is allowing sqlauthentication or not.select that server -> right click it-> select  properties  -> in the window, select security -> check what is the server authentication. it should be  sqlserver and windows authentica...

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
Hello, I am having some trouble with my login for my website. I have had a working login up to today, whereby a had 2 roles and a number of users. However, since I removed some of the roles and added new ones in the SQL Server Management Tool I now recieve this error when attempting to log in: Cannot open user default database. Login failed.Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. I have never seen this before and it is strange seeming as I only change the roles. I have also browsed through all the databases within SQL Server Management Studio and I cannot find user &#...

Problem in getting logged in user Name for ASPX page with (even with this.User.Identity.Name)
Hi  friends,  I am creating an application that takes current logged in user and displays on the page itself. for this I am getting the user name in PageLoad function by using this.User.Identity.Name and then storing the value in a hidden variable for aspx page. I am using this hidden  variable to display the name of the user. I am using Windows authentication for this. Now problem that I am getting is that when multiple user launch the application from different machine and if they click simultaneously, name of one user appears on the paged displayed on the machine of ot...

Mining of a website to get the user names of its users
Hi, I have to do a application in which we have to trace  a website to get the user name of the uers in that website.Kindly give me idea or code to implement this.                                       Thanking you  If it's your website, I don't see why you would need to do this- you would know from the contents of your users database table. If it's not your own website, this is not c...

Getting the user name of the currently logged in user
I'm writing my first custom module. Just as an experimental project I would just display information about the currently logged in user. I can get the User Id, but I don't know where to get the rest of the information. How do I get this? Hi, Just create a new UserController to get the information about one user via the method GetUser(PortalId, UserId) and store it into a UserInfo. Then you can get the rest of the information from this UserInfo [VB] Dim myUser As New UserInfo Dim myUserController As New UserController myUser = myUserController.GetUser(PortalId, Use...

Web resources about - Get the User Name for a login user - asp.net.sql-datasource

Login - Wikipedia, the free encyclopedia
Logging in is usually used to enter a specific page, which trespassers cannot see. Once the user is logged in, the login token may be used to ...

Yahoo To Facebook, Google Users: Login With Yahoo
Facebook and Google users will soon no longer be able to use credentials from those sites to log in to Yahoo services such as fantasy sports ...

Introducing Login Approvals - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Introducing Login Approvals geschrieben. Du kannst den vollständigen Text hier lesen.

Login - Facebook-Entwickler
Facebook Login is a secure and easy way for people to login to your app or website. Learn more about its features and why you should use it for ...

St George Bank internet banking outage: customers cannot login or transfer funds
ST GEORGE Bank customers have been left stranded by an internet banking outage that has thrown southern long weekend plans into disarray.

Apple TV apps can now support Facebook login w/ the company’s new tvOS SDK
... that using the Facebook SDK on tvOS will allow developers to build “immersive” social experiences on the platform including tools like login, ...

Q3 Social Logins: Google Makes Slow Gains; Facebook Indomitable
... The Q3 report from social identity management provider Gigya is evidence of this fact. While there have been some changes in the social login ...

Hello Windows Hello: Firmware Update Adds Biometric Login To Surface Pro 4 And Surface Book
... Pro 4 . One of the most exciting additions to the convertible tablet from Microsoft was the implementation of Windows Hello biometric login ...

Price Drop: Air Login
Air Login 1.2 Device: iOS Universal Category: Business Price: Free, Version: 1.2 ( iTunes ) Description: Wherever you go, there's your Mac. ...

Windows Hello facial logins on the new Surfaces are rather impressive
Extremely quick and effort-free biometric authentication just from looking at your PC.

Resources last updated: 11/27/2015 3:26:50 AM