0

私は stachoverflow の新しいユーザーです。IIS で正常に動作する Active Directory からユーザーを認証するイントラネット用の 1 つの Web アプリケーションを開発していますが、正常に動作する Active Directory のグループからデータ (すべてのユーザー名) を取得する際に問題が発生していますローカルサーバー。IIS では例外エラーが発生します - System.DirectoryServices.DirectoryServicesCOMException: ログオン失敗: 不明なユーザー名またはパスワードが正しくありません。IIS Windows認証で有効化され、その他は無効化されています

My code is:
Web.config file:
<authentication mode="Windows">
            <forms loginUrl="~/TTracker/Login.aspx" timeout="600"></forms>
        </authentication>

<authorization>
            <deny users="?"/>
            <allow users="*" />


        </authorization>
    <identity impersonate="true" />


Code for retrieving data:

using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using (HostingEnvironment.Impersonate())
            {
                DropDownList1.Items.Add(new ListItem("-Select-", ""));
                string grpname = "Group1";                
                PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain");
                GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, grpname);
                if (grp != null)
                {
                    foreach (Principal p in grp.GetMembers(false))
                    {
                        DropDownList1.Items.Add(p.SamAccountName + "-" + p.DisplayName);

                    }
                    grp.Dispose();
                    ctx.Dispose();
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("We did not find that group.");
                    Console.ReadLine();
                }
            }


this is my code for retrieving data from active directory which works fine locally but not works on IIS.

It will be great help if any one solve this issue.

Thanks in advance.
4

1 に答える 1

0

なりすまし関連です。

以下をご確認ください。

アカウントを偽装して AD で処理できます。

ASP.NET 偽装 http://msdn.microsoft.com/en-us/library/aa292118(VS.71).aspx そして、このドキュメントを読んでください。

ハウツー: (ほとんど) C# 経由の Active Directory のすべて http://www.codeproject.com/KB/system/everythingInAD.aspx

于 2013-04-30T11:46:27.903 に答える