AD forms authentication

Discussion in 'ASP .Net Security' started by hari, Aug 20, 2004.

  1. hari

    hari Guest

    I am trying to authenticate to ad using this how-to
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/secnetlpMSDN.asp

    The server is W2k3 and auth hangs here:
    ****************************************************************************
    ****
    string adPath = @"mypath";
    LdapAuthentication adAuth = new LdapAuthentication(adPath);
    lblError.Text = "I made it this far!";
    if(true == adAuth.IsAuthenticated(txtDomainName.Text, txtUserName.Text,
    txtPassword.Text))
    {
    // Retrieve the user's groups
    lblError.Text = " I got the groups";
    string groups = adAuth.GetGroups();
    // Create the authetication ticket
    FormsAuthenticationTicket authTicket = new
    FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now,
    DateTime.Now.AddMinutes(60), false, groups);
    // Now encrypt the ticket.
    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
    // Create a cookie and add the encrypted ticket to the cookie as data.
    HttpCookie authCookie = new
    HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
    // Add the cookie to the outgoing cookies collection.
    Response.Cookies.Add(authCookie);
    lblError.Text = "Success!";
    // Redirect the user to the originally requested page
    Response.Redirect( FormsAuthentication.GetRedirectUrl(txtUserName.Text,
    false));
    }
    else
    {
    lblError.Text = "Authentication failed, check username and password.";

    }
    }
    catch(Exception ex)
    {
    lblError.Text = "Error authenticating. " + ex.Message;
    }

    ********************************************************
    The error is this:
    Error authenticating. Error obtaining group names. The specified domain
    either does not exist or could not be contacted

    I know that the server is being contacted and that the username is being
    queried, because I can move the username a recieve a "user not found error".
    I cannot figure out why the program is unable to access the groups. I
    suspect the permissions in W2k3 are not letting the program access the
    groups, but I am lost as to how to resolve this.

    MAny Thanks
    Harry
    hari, Aug 20, 2004
    #1
    1. Advertising

  2. Check your LDAP path or get it from you Network Adimin.
    Cheers


    "hari" <mackeyha2athotmaildotcom> wrote in message
    news:...
    > I am trying to authenticate to ad using this how-to
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/ht
    ml/secnetlpMSDN.asp
    >
    > The server is W2k3 and auth hangs here:
    >

    ****************************************************************************
    > ****
    > string adPath = @"mypath";
    > LdapAuthentication adAuth = new LdapAuthentication(adPath);
    > lblError.Text = "I made it this far!";
    > if(true == adAuth.IsAuthenticated(txtDomainName.Text,

    txtUserName.Text,
    > txtPassword.Text))
    > {
    > // Retrieve the user's groups
    > lblError.Text = " I got the groups";
    > string groups = adAuth.GetGroups();
    > // Create the authetication ticket
    > FormsAuthenticationTicket authTicket = new
    > FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now,
    > DateTime.Now.AddMinutes(60), false, groups);
    > // Now encrypt the ticket.
    > string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
    > // Create a cookie and add the encrypted ticket to the cookie as

    data.
    > HttpCookie authCookie = new
    > HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
    > // Add the cookie to the outgoing cookies collection.
    > Response.Cookies.Add(authCookie);
    > lblError.Text = "Success!";
    > // Redirect the user to the originally requested page
    > Response.Redirect(

    FormsAuthentication.GetRedirectUrl(txtUserName.Text,
    > false));
    > }
    > else
    > {
    > lblError.Text = "Authentication failed, check username and

    password.";
    >
    > }
    > }
    > catch(Exception ex)
    > {
    > lblError.Text = "Error authenticating. " + ex.Message;
    > }
    >
    > ********************************************************
    > The error is this:
    > Error authenticating. Error obtaining group names. The specified domain
    > either does not exist or could not be contacted
    >
    > I know that the server is being contacted and that the username is being
    > queried, because I can move the username a recieve a "user not found

    error".
    > I cannot figure out why the program is unable to access the groups. I
    > suspect the permissions in W2k3 are not letting the program access the
    > groups, but I am lost as to how to resolve this.
    >
    > MAny Thanks
    > Harry
    >
    >
    Patrick.O.Ige, Aug 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Connell
    Replies:
    1
    Views:
    544
    Natty Gur
    Oct 21, 2003
  2. Eric
    Replies:
    2
    Views:
    1,454
    Tommy
    Feb 13, 2004
  3. JEFF
    Replies:
    1
    Views:
    1,012
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=
    Nov 12, 2007
  4. Keltex
    Replies:
    1
    Views:
    395
    Dominick Baier [DevelopMentor]
    Jan 24, 2006
  5. Eric
    Replies:
    2
    Views:
    498
Loading...

Share This Page