C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » Silverlight »

To check case sensitive in login screen ,silverlight 3 with c#


Posted Date: 12 Oct 2009      Posted By: asha      Member Level: Silver     Points: 1   Responses: 3



Hai,

silverlight 3 with c#:

i wrote program for loginscreen,my guide told me the username and password is should be case sensitive.my database is sqlserver 2005. tel me how to make the username and password case sensitive one.. send me the sample program ...

Regards
asha





Responses

Author: Lalji    12 Oct 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

try this code.

private bool ValidateUser( string userName, string passWord )
{
SqlConnection conn;
SqlCommand cmd;
string lookupPassword = null;

// Check for invalid userName.
// userName must not be null and must be between 1 and 15 characters.
if ( ( null == userName ) || ( 0 == userName.Length ) || ( userName.Length > 15 ) )
{
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Input validation of userName failed." );
return false;
}

// Check for invalid passWord.
// passWord must not be null and must be between 1 and 25 characters.
if ( ( null == passWord ) || ( 0 == passWord.Length ) || ( passWord.Length > 25 ) )
{
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Input validation of passWord failed." );
return false;
}

try
{
// Consult with your SQL Server administrator for an appropriate connection
// string to use to connect to your local SQL Server.
conn = new SqlConnection( "server=localhost;Integrated Security=SSPI;database=pubs" );
conn.Open();

// Create SqlCommand to select pwd field from users table given supplied userName.
cmd = new SqlCommand( "Select pwd from users where uname=@userName", conn );
cmd.Parameters.Add( "@userName", SqlDbType.VarChar, 25 );
cmd.Parameters["@userName"].Value = userName;

// Execute command and fetch pwd field into lookupPassword string.
lookupPassword = (string) cmd.ExecuteScalar();

// Cleanup command and connection objects.
cmd.Dispose();
conn.Dispose();
}
catch ( Exception ex )
{
// Add error handling here for debugging.
// This error message should not be sent back to the caller.
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Exception " + ex.Message );
}

// If no password found, return false.
if ( null == lookupPassword )
{
// You could write failed login attempts here to event log for additional security.
return false;
}

// Compare lookupPassword and input passWord, using a case-sensitive comparison.
return ( 0 == string.Compare( lookupPassword, passWord, false ) );

}



Author: Prabu    15 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

http://www.codeproject.com/KB/web-security/formsroleauth.aspx








Regards
kprabu.007@gmail.com



Author: Prabu    15 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

http://beta.codeproject.com/KB/web-security/formsroleauth.aspx

http://www.codeproject.com/KB/silverlight/SilverlightLogging.aspx






Regards
kprabu.007@gmail.com



Post Reply
You must Sign In to post a response.
Next : Add row in silverlight datagrid
Previous : Silverlight 3.0 application run in mobile application device
Return to Discussion Forum
Post New Message
Category: Silverlight

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use