2017-05-15 3 views
0

送信者が特定のADグループに属している場合、C#コードのチェックを実行するnettcpbindingを使用して、WindowServiceでホストされているWCFサービスがあります。はサーバー側のWCF呼び出し元のActiveDirectoryグループに対して検証します

可能ですか?もしそうなら、どうですか?

+0

ことは可能ですが、実装は、exのために(アプリケーション・トポロジーに依存します十分な、どのようにサービスがホストされている:IIS、Windowsサービス、コンソールアプリケーションe.t.c.は、Windows認証KerberosまたはNTLM e.t.cである、同じネットワーク/ドメインでサービスにアクセスするクライアントです)。 –

+0

@lonut Ungureanu - WindowsService(質問を更新しました) – Joezer

答えて

1

まあWCFクライアントとサーバーが同じドメイン上にあると仮定して、あなたがそのようなこと行うことができます。クライアント側では

を、あなたはクライアントを認証するためのウィンドウIDを使用して許可する:

using System.Security.Principal; 
.... 
ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); 
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification; 
それがグループに属している場合、サーバー側で

は、発信者の窓のアイデンティティとテストをretrive:

WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity; 
    WindowsPrincipal windowsPrincipal = new WindowsPrincipal(callerWindowsIdentity); 
    var isInRole = windowsPrincipal.IsInRole("Users"); 
関連する問題