Active Directory用户与asp.net的通信

Active Directory用户与asp.net的通信,asp.net,active-directory,forms-authentication,Asp.net,Active Directory,Forms Authentication,我在我的机器上安装了VM player,并在里面安装了windows 2008标准内核。还可以通过命令提示符为特定用户添加用户和组,如下所示, 创建用户 dsadd user "cn=username,cn=users,dc=myname,dc=ca" -pwd password -disabled no creating group dsadd group "cn=groupname,cn=users,dc=myname,dc=ca" Also added user to the existi

我在我的机器上安装了VM player,并在里面安装了windows 2008标准内核。还可以通过命令提示符为特定用户添加用户和组,如下所示, 创建用户

dsadd user "cn=username,cn=users,dc=myname,dc=ca" -pwd password -disabled no
creating group
dsadd group "cn=groupname,cn=users,dc=myname,dc=ca"
Also added user to the existing group as below,
dsmod group "cn=groupname,cn=users,dc=myname,dc=ca" -addmbr "cn=username,cn=users,dc=myname,dc=ca"
现在,我通过本地机器上的asp.net应用程序连接这些用户,如下所示, Web.config设置

<authentication mode="Forms">
      <forms loginUrl="logon.aspx" name="adAuthCookie" timeout="10" path="/"/>
    </authentication>
    <authorization>
      <deny users="?"/>
      <allow users="*"/>
    </authorization>
其中我在string groups=adAuth.GetGroups()中得到异常;如下 “身份验证错误。获取组时出错。用户名不正确或密码错误。”

请让我知道我是否犯了一些错误,或者请让我知道我是如何找到关联用户组的

问候
Sangeetha

您是否从msdn()获取了LdapAuthentication类?你能给我们看一下这个类的代码吗(如果不是太长的话)?
void Login_Click(object sender, EventArgs e)
    {
        string adPath = "LDAP://domainaddress:389/DC=somename,DC=m"; //Path to your LDAP directory server
      LdapAuthentication adAuth = new LdapAuthentication(adPath);
      try
      {


        if(true == adAuth.IsAuthenticated(txtDomain.Text, txtUsername.Text, txtPassword.Text))
        {
            FormsAuthentication.SetAuthCookie(txtUsername.Text.Trim(), false);

            string groups = adAuth.GetGroups();

         //Create the ticket, and add the groups.
         bool isCookiePersistent = chkPersist.Checked;
         FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,
           txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups);
---------
-------
}