I'm using a NegotiateStream to authenticate a client/server application. The server side code looks like this:
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;
}
The client side code looks like this:
SecureStream = new NegotiateStream(Stream, true);
SecureStream.AuthenticateAsClient();
if (!SecureStream.IsAuthenticated)
{
return false;
}
The client and server can be run on separate network segments of the same domain. So if they're on a different segment than the domain controller is, and the internet connection goes down, they should be able to operate in offline fashion. The problem is, some of the domains are configured so users can't authenticate in a domain disconnected mode (apparently turning that functionality off is a security measure).
So I'm trying to figure out an authentication model that will allow me to authenticate non-domain users as a fallback position when the domain is not available.