2017-05-15 51 views
0

我有一个WCF服务,托管在WindowService中,使用nettcpbinding,如果发件人属于特定的AD组,需要在其中执行检查。针对服务器端的ActiveDirectory组的WCF调用程序进行验证

可能吗?如果是这样,怎么样?

+0

这是可能的,但实现取决于应用程序的拓扑结构(为前充足,服务如何托管:IIS,Windows服务,控制台应用程序e.t.c.是在同一网络/域中访问服务的客户端,是windows身份验证Kerberos或NTLM e.t.c.)。 –

+0

@lonut Ungureanu - WindowsService(更新了问题) – Joezer

回答

1

那么假设WCF客户端和服务器在同一个域,你可以做这样的事情:

在客户端,您允许使用Windows身份验证客户端:

using System.Security.Principal; 
.... 
ServiceReference.ServiceClient client = new ServiceReference.ServiceClient(); 
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification; 

在服务器端,你retrive来电Windows标识和测试它是否属于组:

WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity; 
    WindowsPrincipal windowsPrincipal = new WindowsPrincipal(callerWindowsIdentity); 
    var isInRole = windowsPrincipal.IsInRole("Users"); 
相关问题