2014-12-24 11 views
0

특정 사용자가 DeployUsersProduction 그룹의 구성원이라는 것을 알 수없는 것 같습니다. 여기에 지금까지 가지고 무엇을 : 내가있어사용자가 서비스에서 특정 글로벌 그룹의 회원 자격을 갖는 방법을 찾는 방법?

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 
public Modes GetDeployMode() 
{ 
    bool isProd = false; 

    WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); 
    if (windowsIdentity == null || windowsIdentity.Groups == null) { return Modes.DUS; } 

    foreach (IdentityReference identityReference in windowsIdentity.Groups) 
    { 
     try 
     { 
      var reference = identityReference; 
      string group = reference.Translate(typeof (NTAccount)).Value.Trim(); 

      if (!String.Equals(group, "DeployUsersProduction", StringComparison.OrdinalIgnoreCase)) { continue; } 

      isProd = true; 
      break; 
     } 
     catch (Exception ex) 
     { 
      // Silent catch due to the [Some or all identity references could not be translated] 
      // error that sometimes occurs while trying to map an identity. 
     } 
    } 

    return isProd ? Modes.Prod : Modes.DUS; 
} 

모든 설정, SPN, DB, 파마 등은 지금까지 내가 말할 수있는 수정합니다. Modes.Prod를 반환해야하는 사용자가 한 명 있습니다. 에 대한 @DJ 크라에

if (!String.Equals(group, @"DOMAIN\DeployUsersProd", StringComparison.OrdinalIgnoreCase)) { continue; } 

특별 감사 : 내 접근 방식이 잘못했다, 내가 내 나는 그것의 도메인과 검색 한 그룹을 접두사해야한다는 사실은 대답

+0

당신은'PrincipalContext' [Principal.GetGroups] (http://msdn.microsoft.com/en-us/library/bb335571%28v=vs.110%29.aspx) – MethodMan

+0

흠을 사용하려고하는 것에 대해 생각해 보셨습니까? ..'System.DirectoryServices.AccountManagement'를 추가하려고하면'DirectoryServices' 네임 스페이스조차 인식하지 못합니다. –

+0

참조를 추가하고 참조를 마우스 오른쪽 버튼으로 클릭하여 참조를 추가해야합니다. -> 추가 ... – MethodMan

답변

0

이었다되지 않았다 내가 이것을 알아낼 수 있도록 그룹을 출력 한 내 자신의 콘솔 앱을 작성하도록 이끌어 준 링크!