CodeSolution.org

Your Problems Our Solutions

Skip to content
  • Home
  • All Articles
  • .Net Core
  • SQL Server
  • Interview Questions
  • C# Logical Questions
  • Follow
CodeSolution.org

Single Sign ON Authentication

Share on Facebook Share
Share on TwitterTweet
Share on LinkedIn Share

Single Sign ON means Emp Id will be displayed from your active directory. Application will show Emp id of the logged in User.

Single Sign On Authentication

Single Sign On Authentication

User Id belongs to your Window id.

LoginPage.aspx Page

<table width="100%" class="loginblock" style="text-align: center; vertical-align: middle;">
    <tr>
        <td height="35px">&nbsp;
        </td>
    </tr>
    <tr>
        <td height="20px">&nbsp;
        </td>
    </tr>
    <tr>
        <td align="center" style="font-family: Verdana">
            <h3>
                <b>USER &nbsp; </b>
                <asp:Label ID="lblCurrentUser" runat="server" Font-Bold="true"></asp:Label></h3>
            <br />
            <asp:Button ID="lnkEnterSite" runat="server" Visible="true" OnClick="lnkEnterSite_Click"
                Text="ENTER" Width="100px" />
        </td>
    </tr>
</table>

Code behind Page

On the page load event write lblCurrentUser.Text =  Environment.UserName.ToUpper();

This will display Emp id on the login page.

protected void Page_Load(object sender, EventArgs e)
{
  lblCurrentUser.Text = Environment.UserName.ToUpper();
}

On Enter button click event write the following code

protected void lnkEnterSite_Click(object sender, EventArgs e)
{
   if (!string.IsNullOrEmpty(lblCurrentUser.Text.Trim()))
      {
        if (Authenticate(lblCurrentUser.Text.Trim()))
           {
             Response.Redirect(Your Default Page);
           }
         else
           {
             ErrorMsg="You do not have access to this site";
           }
      }
     else
      {
      ErrorMsg="No Emp Id found.";
      }
}

Authenticate with database –  check user exists in user table

protected bool Authenticate(String userName)
{
   If exists
      Return true
   Else
      Return false
}
Share on Facebook Share
Share on TwitterTweet
Share on LinkedIn Share

Related posts:

  1. Active Directory Authentication
  2. Asp.Net Reports with Report viewer
  3. What are the different kinds of controls in WPF?
  4. Explain ASP.NET MVC pipeline?
This entry was posted in Asp.Net and tagged Login with Single Sign On Authentication, Single Sign On Authentication, Single Sign on Authentication in asp.net on December 29, 2014 by Hitesh Kumar.
Avatar

About Hitesh Kumar

A Software Developer with more than 5+ years of rich experience in Software Development in Microsoft Dot Net Technology.

View all posts by Hitesh Kumar →

Post navigation

Active Directory Authentication →

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Categories

  • Asp.Net (43)
  • Asp.Net MVC (5)
  • Asp.Net Rest API (2)
  • ASP.Net Web API (4)
  • C# (45)
  • Entity Framework (1)
  • HTML5 (6)
    • Canvas (5)
  • Interview Questions (178)
    • Asp.Net (10)
    • Asp.Net MVC (32)
    • Asp.Net Web API (1)
    • C# (30)
    • Entity framework (15)
    • JAVA (7)
    • LINQ (6)
    • SQL Server (30)
    • WCF (12)
    • WPF (40)
  • JAVA (32)
    • Design Pattern (3)
    • Hibernate (3)
    • Spring Tutorial (2)
  • JavaScript (3)
  • Jquery (5)
  • Linux (7)
  • Logical Problems (10)
  • My SQL (5)
  • PHP (1)
  • Spring (3)
  • SQL Server (38)
  • Uncategorized (1)
  • Web Service (2)
  • Wicket Framework (2)
  • WPF (1)
  • XML (1)

Recent Posts

  • Delete, Backspace, Tab and Arrow keys are not working in Firefox when applying validation.
  • How to encode URI components in javascript?
  • Calculate time between two dates
  • Calculate days between two dates in jquery.
  • Fizz Buzz game C#

Quick Links

ALL ARTICLES
INTERVIEW QUESTIONS
C# LOGICAL QUESTIONS
FOLLOW
CONTACT US

communities & Groups

Facebook Group

Follow us on social Network

Follow on Facebook Share
Follow on TwitterTweet
Follow on LinkedIn Share
Proudly powered by WordPress
Scroll Up