Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Posts
    8

    Unanswered: sql server login

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
    bool Authenticated = false;
    Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserNam e, Login1.Password);
    e.Authenticated = Authenticated;
    if (Authenticated == true)
    {
    Response.Redirect("Home.aspx");
    }
    }
    private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
    {
    bool boolReturnValue = false;
    // Insert code that implements a site-specific custom
    // authentication method here.
    // This example implementation always returns false.
    string strConnection = "server=dtpxp-skumari;database=master;uid=sa;pwd=;";
    SqlConnection Connection = new SqlConnection(strConnection);
    String strSQL = "Select * From Employee";
    SqlCommand command =new SqlCommand(strSQL, Connection);
    SqlDataReader Dr;
    Connection.Open();
    Dr=command.ExecuteReader();
    while (Dr.Read())
    {
    if ((UserName == Dr["name"].ToString()) & (Password == Dr["Password"].ToString()))
    {
    boolReturnValue = true;
    }
    Dr.Close();
    return boolReturnValue;
    }
    }

    gettin an error 'Login.SiteLevelCustomAuthenticationMethod(string, string)'; not all code paths return a value filelogin.aspx.cs........anyone have an idea what the problem is.cheers

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Did you copy and paste this?
    Code:
    Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserNam e, Login1.Password);
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2008
    Posts
    8

    sql server login

    yes copy n pasted it from another site n changed it to suit my database i hope.....ne ideas wats wrong.....tanks 4 d reply.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sorry, didn't make it quite clear in my previous post; let's try again
    Code:
    Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserNam e, Login1.Password);
    George
    Home | Blog

  5. #5
    Join Date
    Jan 2008
    Posts
    8
    smart man georgie

  6. #6
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    my favorite part of this code is that it returns every employee record and checks the user name and password at the client instead of sending those parameters to the database as part of a stored procedure.

    I have 125K names in my enterprise directory. I might get someone here to impliment this for fun.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •