1. In IIS 6 set the following in the application pool for the website.

How to use a network domain account for an ASP.NET applications which gets the logged on user name from the computer using?
2. Create the website and assign the above application pool.
3. Add the domain service account to the IIS WPG group on the hosting server.

Go to Computer Management > Local Users and Groups >Groups>IIS WPG. Right click on IIS WPG and go to properties. Add domain service account.
4. In the web.config of the application add the following connection string
<add name=“Connection Name“ connectionString=“Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=True” providerName=“System.Data.SqlClient“ />
5. In the web.config also add identity tag
<system.web> <identity impersonate=“true“ userName=“DomainName\DomainAccountName“ password=“DomainAccontPassword“/> <system.web>
6. Now in you code if you use the code below it will show the logged on user name
ASP.NET
<div class=”group”>
<asp:Label ID=”lblSearchUserName” runat=”server”>User Name : </asp:Label> <asp:TextBox ID=”txtSearchUserName” CssClass=”Search” MaxLength=”10″ ValidationGroup=”vgSearchForm” runat=”server” /> (Eg.<%=Replace(Trim(Request.ServerVariables.Item(“LOGON_USER”).ToLower), “domainName\”, “”)%>) <br />
</div>
VB.NET
If (Not String.IsNullOrEmpty(Request.ServerVariables.Item(“LOGON_USER”))) Then Dim LogonUserName As String = Trim(Request.ServerVariables.Item(“LOGON_USER”).ToLower)
~~
~~
Else
Response.Redirect(“Resources/Error/LogOnNameError.htm”)
End If ‘LOGON_USER
Reference:
http://msdn.microsoft.com/en-us/library/72wdk8cc.aspx
Leave a Reply