How to use a network domain account for an ASP.NET applications which gets the logged on user name from the computer?

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?

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.

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=TrueproviderName=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

 

About Diganta Kumar
Diganta Kumar has years of experience in architecting and development of .NET systems to meet complex business needs. Specialized in Intranet and Internet projects. Strong knowledge of Enterprise Content Management (ECM) Systems like Microsoft SharePoint and Elcom Community Manager.NET. I have developed, designed, implemented and configured Legal Aid NSW and Bankstown City Council NSW Intranets.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s