【发布时间】:2010-09-17 19:44:34
【问题描述】:
我正在使用 NegotiateStream 来验证客户端/服务器应用程序。服务器端代码如下所示:
SecureStream = new NegotiateStream(Stream, true);
SecureStream.AuthenticateAsServer(
CredentialCache.DefaultNetworkCredentials,
ProtectionLevel.EncryptAndSign,
TokenImpersonationLevel.Identification);
if (!SecureStream.IsAuthenticated)
{
return false;
}
WindowsPrincipal principal = new WindowsPrincipal(
(WindowsIdentity)SecureStream.RemoteIdentity);
// ExpectedRoles is a string[] of possible roles
foreach (string role in ExpectedRoles)
{
if (principal.IsInRole(role))
return true;
}
客户端代码如下所示:
SecureStream = new NegotiateStream(Stream, true);
SecureStream.AuthenticateAsClient();
if (!SecureStream.IsAuthenticated)
{
return false;
}
客户端和服务器可以运行在同一个域的不同网段上。因此,如果它们与域控制器位于不同的网段,并且互联网连接中断,它们应该能够以离线方式运行。问题是,某些域的配置使用户无法在域断开模式下进行身份验证(显然关闭该功能是一种安全措施)。
因此,我正在尝试找出一种身份验证模型,该模型允许我在域不可用时对非域用户进行身份验证作为后备位置。
【问题讨论】:
标签: c# dns windows-authentication offline