Single Sign ON means Emp Id will be displayed from your active directory. Application will show Emp id of the logged in User.
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"> </td> </tr> <tr> <td height="20px"> </td> </tr> <tr> <td align="center" style="font-family: Verdana"> <h3> <b>USER </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 }