인증을 처리하기 위해 ServiceAuthorizationManager를 구현했습니다. 그러나 ServiceAuthorizationManager 메서드가 호출 될 때 Active Directory에 액세스 할 수없는 것 같습니다. 내 서비스의 Thread.CurrentPrincipal.Identity.Name이 비어 있습니다. 나는 이것이 광고를 쿼리 할 때 자격 증명으로 사용될 것이라고 생각합니다. 내 서비스 클래스를 만든 후에도 AD를 쿼리하려고하면 작동하며 Thread.CurrentPrincipal.Identity.Name은 올바르게 채워집니다. 문제는 각각의 [OperationContract] 메서드에서 유효성 검사를 수행해야만하는 것입니다.
public static void CheckPermissions(List<string> RequiredGroupNames)
{
bool ThrowException;
WindowsIdentity MyIdentity = OperationContext.Current.ServiceSecurityContext.WindowsIdentity;
WindowsPrincipal p = new WindowsPrincipal(MyIdentity);
ThrowException = true;
foreach (string RequiredGroupName in RequiredGroupNames)
{
if (p.IsInRole(RequiredGroupName))
{
ThrowException = false;
}
}
if (ThrowException == true)
{
throw new FaultException(MyIdentity.Name + ": You don't have permission for this operation!");
}
}
내가 OP로 .NET 4.0하지만,하지 3.0을 사용 :