Principal.IsMemberOf(GroupPrincipal)
(MSDN)이 다음 테스트에서 Domain Computers
그룹에 대해 false negative를 반환하는 이유는 무엇입니까?Principal.IsMemberOf()가 일부 그룹에 대해 false negative를 반환하는 이유는 무엇입니까?
[TestMethod]
public void DomainComputerTest()
{
var distinguishedName = "CN=MyMachine,DC=SomeDomain,DC=local";
using(var pc = new PrincipalContext(ContextType.Domain, "SomeDomain.local", "UserName", "Password"))
using(var computer = ComputerPrincipal.FindByIdentity(pc, IdentityType.DistinguishedName, distinguishedName))
{
Assert.IsNotNull(computer);
// Get the groups for the computer.
var groups = computer.GetGroups().Cast<GroupPrincipal>();
foreach(var group in groups)
{
// Immediately turn around and test that the computer is a member of the groups it returned.
Assert.IsTrue(computer.IsMemberOf(group), "Computer is not member of group {0}", group.Name);
}
}
}
결과 메시지 : Assert.IsTrue가 실패했습니다. 컴퓨터가 'Domain Computers'그룹의 구성원이 아닙니다.
컴퓨터가 실제로 'GetGroups()'메서드가 올바르게 반환 된 "Domain Computers"그룹의 구성원입니다. 실제로 컴퓨터를 그룹에 추가하려고하면 PrincipalExistsException이 발생합니다.
사용자 및 "도메인 사용자"그룹과 똑같은 동작을 재현 할 수 있습니다. 그룹이 주요 그룹이기 때문에 이것이 가능한가? 이것들이 "기본"그룹이기 때문에 그것입니까?
수정 사항 : 우리는 .NET 4.5.1을 사용하고 있습니다.
어떤 버전의 .NET을 사용합니까? –
4.5.1을 사용 중입니다. 나는 그 정보를 질문에 추가 할 것이다. 감사! – Josh