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

 

Advertisements

Diganta Kumar has architected and developed software for more than a decade for a wide range of industries and development platforms and over the years has filled many roles including program manager, founder, developer, architect, team lead, mentor and project manager. Diganta is founder of two online IT businesses. He is a certified AWS Solutions Architect, certified Professional Scrum Master (PSM I), certified Professional Scrum Developer (PSD I) and ITIL Certified. He has presented at Microsoft Tech.Ed, Microsoft AppFest and Ark Group Intranet conference. He attends AWS Seattle Official Events, Seattle AWS Architects-Engineers, and AWS Cloud Commerce user groups. He likes to help, mentor and manage software development teams to improve and produce great software. He currently work as a Senior Technical Program Manager for Amazon Web Services.

Posted in ASP.NET

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 )

Google+ photo

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

Connecting to %s