2

マシンに VM プレーヤーをインストールし、内部に 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>

認証用スクリプト

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);
---------
-------
}

文字列グループで例外が発生している場所 = adAuth.GetGroups(); 以下のように、「認証エラー。グループの取得エラー。ユーザー名が正しくないか、パスワードが正しくありません。」

間違いがある場合はお知らせください。または、関連付けられたユーザーのグループを見つける方法を教えてください。

よろしくサンギータ

4

0 に答える 0