sql server login?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Iwan Petrow

    sql server login?

    Hi,

    I have a database application. In the beginning a user is connected to
    the database. Here I want to check if the user input correct password
    and user name, but I haven't find any exception for this concrete task.
    Is there any specific exception for this purpose or I have to use
    SqlException? And in the second case how could I check that the user
    don't exist or the password is incorrect (I want to check also if there
    is connection to the server)?

    Thanks.

  • Christopher Kimbell

    #2
    Re: sql server login?

    The easiest way is just to catch the Exception that is thrown. If you are
    using SqlClient the exception would be SqlException.
    The message of the SqlException will tell you what went wrong, I can't
    remeber the exact syntax but is someting like this;

    "Login for user 'XXX' failed"
    "Server not found"

    If you decide to implement something of your own, make sure that the
    messages are general, not specific. Don't issue a message like "The user XXX
    does not exist" or "Password for user 'XXX' was incorrect". An attacker
    would know that the username is valid but the passsword is not, instead of
    not knowing if the username or password is valid.

    Chris


    "Iwan Petrow" <xxxxyz@abv.b g> wrote in message
    news:1118817646 .073350.320410@ g47g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi,
    >
    > I have a database application. In the beginning a user is connected to
    > the database. Here I want to check if the user input correct password
    > and user name, but I haven't find any exception for this concrete task.
    > Is there any specific exception for this purpose or I have to use
    > SqlException? And in the second case how could I check that the user
    > don't exist or the password is incorrect (I want to check also if there
    > is connection to the server)?
    >
    > Thanks.
    >[/color]


    Comment

    • Iwan Petrow

      #3
      Re: sql server login?

      Thanks.

      But I want the user to see some message when he or she logs on and
      there is a problem. I see two problems - first: wrong password or user
      name; second: cannot connect to the server (others reasons - for
      example the server is not reachable).

      What could I do in this case?

      Comment

      Working...