// IIS and NCL have different enums/values for the various settings // therefore we will have to remap. AuthenticationSchemes RemapAuthenticationSchemes(AuthFlags flags, string[] providers) { // The default value for the authetication in IIS is anonymous AuthenticationSchemes retValue = AuthenticationSchemes.None; if ((flags & AuthFlags.AuthAnonymous) != 0) { retValue = retValue | AuthenticationSchemes.Anonymous; } if ((flags & AuthFlags.AuthBasic) != 0) { retValue = retValue | AuthenticationSchemes.Basic; } if ((flags & AuthFlags.AuthMD5) != 0) { retValue = retValue | AuthenticationSchemes.Digest; } if ((flags & AuthFlags.AuthNTLM) != 0) { for (int i = 0; i < providers.Length; i++) { if (providers[i].StartsWith(NegotiateAuthProvider, StringComparison.OrdinalIgnoreCase)) { retValue = retValue | AuthenticationSchemes.Negotiate; } else if (string.Compare(providers[i], NtlmAuthProvider, StringComparison.OrdinalIgnoreCase) == 0) { retValue = retValue | AuthenticationSchemes.Ntlm; } else { throw FxTrace.Exception.AsError(new NotSupportedException(SR.Hosting_NotSupportedAuthScheme(providers[i]))); } } } if ((flags & AuthFlags.AuthPassport) != 0) { throw FxTrace.Exception.AsError(new NotSupportedException(SR.Hosting_NotSupportedAuthScheme("Passport"))); } return(retValue); }
private AuthenticationSchemes RemapAuthenticationSchemes(AuthFlags flags, string[] providers) { AuthenticationSchemes none = AuthenticationSchemes.None; if ((flags & AuthFlags.AuthAnonymous) != AuthFlags.None) { none |= AuthenticationSchemes.Anonymous; } if ((flags & AuthFlags.AuthBasic) != AuthFlags.None) { none |= AuthenticationSchemes.Basic; } if ((flags & AuthFlags.AuthMD5) != AuthFlags.None) { none |= AuthenticationSchemes.Digest; } if ((flags & AuthFlags.AuthNTLM) != AuthFlags.None) { for (int i = 0; i < providers.Length; i++) { if (providers[i].StartsWith("negotiate", StringComparison.OrdinalIgnoreCase)) { none |= AuthenticationSchemes.Negotiate; } else { if (string.Compare(providers[i], "ntlm", StringComparison.OrdinalIgnoreCase) != 0) { throw FxTrace.Exception.AsError(new NotSupportedException(System.ServiceModel.Activation.SR.Hosting_NotSupportedAuthScheme(providers[i]))); } none |= AuthenticationSchemes.Ntlm; } } } if ((flags & AuthFlags.AuthPassport) != AuthFlags.None) { throw FxTrace.Exception.AsError(new NotSupportedException(System.ServiceModel.Activation.SR.Hosting_NotSupportedAuthScheme("Passport"))); } return(none); }
private AuthenticationSchemes RemapAuthenticationSchemes(AuthFlags flags, string[] providers) { AuthenticationSchemes none = AuthenticationSchemes.None; if ((flags & AuthFlags.AuthAnonymous) != AuthFlags.None) { none |= AuthenticationSchemes.Anonymous; } if ((flags & AuthFlags.AuthBasic) != AuthFlags.None) { none |= AuthenticationSchemes.Basic; } if ((flags & AuthFlags.AuthMD5) != AuthFlags.None) { none |= AuthenticationSchemes.Digest; } if ((flags & AuthFlags.AuthNTLM) != AuthFlags.None) { for (int i = 0; i < providers.Length; i++) { if (providers[i].StartsWith("negotiate", StringComparison.OrdinalIgnoreCase)) { none |= AuthenticationSchemes.Negotiate; } else { if (string.Compare(providers[i], "ntlm", StringComparison.OrdinalIgnoreCase) != 0) { throw FxTrace.Exception.AsError(new NotSupportedException(System.ServiceModel.Activation.SR.Hosting_NotSupportedAuthScheme(providers[i]))); } none |= AuthenticationSchemes.Ntlm; } } } if ((flags & AuthFlags.AuthPassport) != AuthFlags.None) { throw FxTrace.Exception.AsError(new NotSupportedException(System.ServiceModel.Activation.SR.Hosting_NotSupportedAuthScheme("Passport"))); } return none; }
// IIS and NCL have different enums/values for the various settings // therefore we will have to remap. AuthenticationSchemes RemapAuthenticationSchemes(AuthFlags flags, string[] providers) { // The default value for the authetication in IIS is anonymous AuthenticationSchemes retValue = AuthenticationSchemes.None; if ((flags & AuthFlags.AuthAnonymous) != 0) { retValue = retValue | AuthenticationSchemes.Anonymous; } if ((flags & AuthFlags.AuthBasic) != 0) { retValue = retValue | AuthenticationSchemes.Basic; } if ((flags & AuthFlags.AuthMD5) != 0) { retValue = retValue | AuthenticationSchemes.Digest; } if ((flags & AuthFlags.AuthNTLM) != 0) { for (int i = 0; i < providers.Length; i++) { if (providers[i].StartsWith(NegotiateAuthProvider, StringComparison.OrdinalIgnoreCase)) { retValue = retValue | AuthenticationSchemes.Negotiate; } else if (string.Compare(providers[i], NtlmAuthProvider, StringComparison.OrdinalIgnoreCase) == 0) { retValue = retValue | AuthenticationSchemes.Ntlm; } else { throw FxTrace.Exception.AsError(new NotSupportedException(SR.Hosting_NotSupportedAuthScheme(providers[i]))); } } } if ((flags & AuthFlags.AuthPassport) != 0) { throw FxTrace.Exception.AsError(new NotSupportedException(SR.Hosting_NotSupportedAuthScheme("Passport"))); } return retValue; }