AD forms authentication

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default AD forms authentication

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

    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.Tex t,
    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 Guest

  2. Similar Questions and Discussions

    1. Accessing htm files without authentication (forms authentication)
      I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But...
    2. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    3. Forms authentication then redirection to a secure web with NT authentication?
      Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've...
    4. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
    5. Forms authentication with Windows authentication
      Hi, I have an ASP.NET web site that uses IIS Basic Authentication and accesses an OLAP Server at various stages. The OLAP Server authentication...
  3. #2

    Default Re: AD forms authentication

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


    "hari" <mackeyha2athotmaildotcom> wrote in message
    news:uefMfmvhEHA.396@TK2MSFTNGP12.phx.gbl...
    > I am trying to authenticate to ad using this how-to
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/ht[/url]
    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.Tex t,
    > 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 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139