.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Jean Paul
satyapriyanayak
SP
Ashutosh Jha
Simon Robert VoIP

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to check password is correct or not.

Posted By: kamlesh     Posted Date: June 08, 2012    Points:5   Category :C#
Hi,
I have one text box where user can add password,
and in background i have to check whether entered password is correct or not.
How to do this. please help me.

Responses
Author: The King             
Posted Date: June 09, 2012     Points: 20   

ASP PAGE CODE


<table class="style1">
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Text="USERNAME"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txtUserName" runat="server" BorderStyle="Solid"
BorderWidth="1px" Height="18px" Width="127px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label2" runat="server" Text="PASSWORD"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="txtPassword" runat="server" BorderStyle="Solid"
BorderWidth="1px" Height="18px" TextMode="Password" Width="127px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Button ID="btnLogin" runat="server" Text="Login" BackColor="White"
BorderStyle="Solid" BorderWidth="1px" onclick="btnLogin_Click" />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Label ID="lbStatus" runat="server"></asp:Label></td>
</tr>
</table>


BACK END CODE C#



    protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True";
SqlCommand cmd = new SqlCommand();
con.Open();
cmd.CommandText = @"SELECT USERNAME FROM USERS_TABLE WHERE USERNAME='"+txtUserName.Text+"' AND PASSWORD='"+txtPassword.Text+"'";
cmd.Connection = con;
object o = cmd.ExecuteScalar();
if (o == null)
{
lbStatus.Text = "Invalid login";
return;
}
Session["username"] = o;
lbStatus.Text = "Success";
con.Close();
}


Author: kamlesh             
Posted Date: June 11, 2012     Points: 20   

Thanks King,
but i know about the connectivity about sql server but i need to check os password
suppose i have one application and application required os password so at that time how to check whether that password is correct or not


Thanks And Regards.
Kamlesh Nikam
Author: kamlesh             
Posted Date: June 11, 2012     Points: 20   

http://stackoverflow.com/questions/3714679/how-get-current-username-and-password-from-windows-operating-system

Thanks And Regards.
Kamlesh Nikam


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend