私は質問があります。正直なところ、質問する方法はあまりよく分かりません。基本的に私はそれを実行すると、私のローカルマシン上で幻想的に動作するコードを少し持っています。私が開発Webサーバーに公開すると失敗します。私はそれがIISセットアップの問題、Web.configの問題かコーディングの問題かどうかはわかりません。C#Active Directory PrincipalContext/UserPrincipal.IsMemberOfエラー
は、ここで私は、ユーザー名とグループに渡すコード
bool isMember = false;
PrincipalContext ADDomain = new PrincipalContext(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(ADDomain, userID);
if (user.IsMemberOf(ADDomain, IdentityType.Name, groupName.Trim()))
{
isMember = true;
}
return isMember;
のスニペットだと、そのユーザーがそのグループのメンバーであれば、それは私に語りました。問題ない。私のマシンでうまく動作します。私は、ウェブサーバにそのコードを公開するために行って、それが失敗し、それがラインを打つ
UserPrincipal user = UserPrincipal.FindByIdentity(ADDomain, userID);
それは、このエラーがスローされます。
[DirectoryServicesCOMException (0x80072020): An operations error occurred.]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +788
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.PropertyValueCollection.PopulateList() +29
System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) +63
System.DirectoryServices.PropertyCollection.get_Item(String propertyName) +163 System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer() +521217
System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit() +51
System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() +141
System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() +42
System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate) +29
System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, String identityValue) +95
Cosmic.Web.Login.btnSubmit_Click(Object sender, EventArgs e) in C:\cosmic\Cosmic.Web\Login.aspx.cs:79
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
これが失敗する可能性が任意のアイデアを?
あなたはそれが何であったかを知っています。 Webサーバーには、Active Directoryにアクセスするための正しい資格情報がありません。そこにいくつかの資格を入れれば、それはかなり良く機能します。ありがとう! – Seril