internal static object GetClientAuthenticationMethod(IPropertyBag propertyBag, ADPropertyDefinition adPropertyDefinition) { AuthenticationMethodFlags authenticationMethodFlags = (AuthenticationMethodFlags)propertyBag[adPropertyDefinition]; AuthenticationMethod authenticationMethod = ADRpcHttpVirtualDirectory.ClientAuthenticationMethodFromFlags(authenticationMethodFlags); return(authenticationMethod); }
internal static void SetClientAuthenticationMethod(object value, IPropertyBag propertyBag, ADPropertyDefinition adPropertyDefinition) { AuthenticationMethod authMethod = (AuthenticationMethod)value; AuthenticationMethodFlags authenticationMethodFlags = ADRpcHttpVirtualDirectory.ClientAuthenticationMethodToFlags(authMethod); propertyBag[adPropertyDefinition] = authenticationMethodFlags; }
internal static object GetIISAuthenticationMethods(IPropertyBag propertyBag) { AuthenticationMethodFlags authenticationMethodFlags = (AuthenticationMethodFlags)propertyBag[ADVirtualDirectorySchema.InternalAuthenticationMethodFlags]; if (authenticationMethodFlags == AuthenticationMethodFlags.None) { authenticationMethodFlags = (AuthenticationMethodFlags.Basic | AuthenticationMethodFlags.Ntlm | AuthenticationMethodFlags.Negotiate); } return(ADVirtualDirectory.AuthenticationMethodFlagsToAuthenticationMethodPropertyValue(authenticationMethodFlags)); }
internal static AuthenticationMethod ClientAuthenticationMethodFromFlags(AuthenticationMethodFlags authenticationMethodFlags) { switch (authenticationMethodFlags) { case AuthenticationMethodFlags.Basic: return(AuthenticationMethod.Basic); case AuthenticationMethodFlags.Ntlm: return(AuthenticationMethod.Ntlm); default: if (authenticationMethodFlags == AuthenticationMethodFlags.NegoEx) { return(AuthenticationMethod.NegoEx); } if (authenticationMethodFlags != AuthenticationMethodFlags.Negotiate) { return(AuthenticationMethod.Misconfigured); } return(AuthenticationMethod.Negotiate); } }
internal static object ExternalAuthenticationMethodsGetter(IPropertyBag propertyBag) { AuthenticationMethodFlags authenticationMethodFlags = (AuthenticationMethodFlags)propertyBag[ADVirtualDirectorySchema.ExternalAuthenticationMethodFlags]; return(ADVirtualDirectory.AuthenticationMethodFlagsToAuthenticationMethodPropertyValue(authenticationMethodFlags)); }
internal static AuthenticationMethodFlags AuthenticationMethodPropertyValueToAuthenticationMethodFlags(MultiValuedProperty <AuthenticationMethod> authenticationMethods) { AuthenticationMethodFlags authenticationMethodFlags = AuthenticationMethodFlags.None; if (authenticationMethods != null) { foreach (AuthenticationMethod authenticationMethod in authenticationMethods) { if (authenticationMethod == AuthenticationMethod.Basic) { authenticationMethodFlags |= AuthenticationMethodFlags.Basic; } else if (authenticationMethod == AuthenticationMethod.Fba) { authenticationMethodFlags |= AuthenticationMethodFlags.Fba; } else if (authenticationMethod == AuthenticationMethod.Ntlm) { authenticationMethodFlags |= AuthenticationMethodFlags.Ntlm; } else if (authenticationMethod == AuthenticationMethod.Digest) { authenticationMethodFlags |= AuthenticationMethodFlags.Digest; } else if (authenticationMethod == AuthenticationMethod.WindowsIntegrated) { authenticationMethodFlags |= AuthenticationMethodFlags.WindowsIntegrated; } else if (authenticationMethod == AuthenticationMethod.LiveIdFba) { authenticationMethodFlags |= AuthenticationMethodFlags.LiveIdFba; } else if (authenticationMethod == AuthenticationMethod.LiveIdBasic) { authenticationMethodFlags |= AuthenticationMethodFlags.LiveIdBasic; } else if (authenticationMethod == AuthenticationMethod.WSSecurity) { authenticationMethodFlags |= AuthenticationMethodFlags.WSSecurity; } else if (authenticationMethod == AuthenticationMethod.Certificate) { authenticationMethodFlags |= AuthenticationMethodFlags.Certificate; } else if (authenticationMethod == AuthenticationMethod.NegoEx) { authenticationMethodFlags |= AuthenticationMethodFlags.NegoEx; } else if (authenticationMethod == AuthenticationMethod.LiveIdNegotiate) { authenticationMethodFlags |= AuthenticationMethodFlags.LiveIdNegotiate; } else if (authenticationMethod == AuthenticationMethod.OAuth) { authenticationMethodFlags |= AuthenticationMethodFlags.OAuth; } else if (authenticationMethod == AuthenticationMethod.Adfs) { authenticationMethodFlags |= AuthenticationMethodFlags.Adfs; } else if (authenticationMethod == AuthenticationMethod.Kerberos) { authenticationMethodFlags |= AuthenticationMethodFlags.Kerberos; } else { if (authenticationMethod != AuthenticationMethod.Negotiate) { throw new ArgumentOutOfRangeException("value"); } authenticationMethodFlags |= AuthenticationMethodFlags.Negotiate; } } } return(authenticationMethodFlags); }
internal static void ExternalAuthenticationMethodsSetter(object value, IPropertyBag propertyBag) { AuthenticationMethodFlags authenticationMethodFlags = ADVirtualDirectory.AuthenticationMethodPropertyValueToAuthenticationMethodFlags((MultiValuedProperty <AuthenticationMethod>)value); propertyBag[ADVirtualDirectorySchema.ExternalAuthenticationMethodFlags] = authenticationMethodFlags; }
internal static MultiValuedProperty <AuthenticationMethod> AuthenticationMethodFlagsToAuthenticationMethodPropertyValue(AuthenticationMethodFlags authenticationMethodFlags) { if (authenticationMethodFlags != AuthenticationMethodFlags.None) { List <AuthenticationMethod> list = new List <AuthenticationMethod>(3); if ((authenticationMethodFlags & AuthenticationMethodFlags.Basic) == AuthenticationMethodFlags.Basic) { list.Add(AuthenticationMethod.Basic); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Fba) == AuthenticationMethodFlags.Fba) { list.Add(AuthenticationMethod.Fba); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Ntlm) == AuthenticationMethodFlags.Ntlm) { list.Add(AuthenticationMethod.Ntlm); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Digest) == AuthenticationMethodFlags.Digest) { list.Add(AuthenticationMethod.Digest); } if ((authenticationMethodFlags & AuthenticationMethodFlags.WindowsIntegrated) == AuthenticationMethodFlags.WindowsIntegrated) { list.Add(AuthenticationMethod.WindowsIntegrated); } if ((authenticationMethodFlags & AuthenticationMethodFlags.LiveIdFba) == AuthenticationMethodFlags.LiveIdFba) { list.Add(AuthenticationMethod.LiveIdFba); } if ((authenticationMethodFlags & AuthenticationMethodFlags.LiveIdBasic) == AuthenticationMethodFlags.LiveIdBasic) { list.Add(AuthenticationMethod.LiveIdBasic); } if ((authenticationMethodFlags & AuthenticationMethodFlags.WSSecurity) == AuthenticationMethodFlags.WSSecurity) { list.Add(AuthenticationMethod.WSSecurity); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Certificate) == AuthenticationMethodFlags.Certificate) { list.Add(AuthenticationMethod.Certificate); } if ((authenticationMethodFlags & AuthenticationMethodFlags.NegoEx) == AuthenticationMethodFlags.NegoEx) { list.Add(AuthenticationMethod.NegoEx); } if ((authenticationMethodFlags & AuthenticationMethodFlags.LiveIdNegotiate) == AuthenticationMethodFlags.LiveIdNegotiate) { list.Add(AuthenticationMethod.LiveIdNegotiate); } if ((authenticationMethodFlags & AuthenticationMethodFlags.OAuth) == AuthenticationMethodFlags.OAuth) { list.Add(AuthenticationMethod.OAuth); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Adfs) == AuthenticationMethodFlags.Adfs) { list.Add(AuthenticationMethod.Adfs); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Kerberos) == AuthenticationMethodFlags.Kerberos) { list.Add(AuthenticationMethod.Kerberos); } if ((authenticationMethodFlags & AuthenticationMethodFlags.Negotiate) == AuthenticationMethodFlags.Negotiate) { list.Add(AuthenticationMethod.Negotiate); } return(new MultiValuedProperty <AuthenticationMethod>(list)); } return(ADVirtualDirectory.EmptyAuthenticationMethodPropertyValue); }
private bool?GetAuthentication(ExchangeVirtualDirectory dataObject, string subVDirName, AuthenticationMethodFlags authFlags) { TaskLogger.LogEnter(); try { string text = dataObject.MetabasePath; if (!string.IsNullOrEmpty(subVDirName)) { text = string.Format("{0}/{1}", text, subVDirName); } if (IisUtility.Exists(text)) { using (DirectoryEntry directoryEntry = IisUtility.CreateIISDirectoryEntry(text, new Task.TaskErrorLoggingReThrowDelegate(this.WriteError), dataObject.Identity)) { bool ignoreAnonymousOnCert = dataObject is ADPowerShellCommonVirtualDirectory; return(new bool?(IisUtility.CheckForAuthenticationMethod(directoryEntry, authFlags, ignoreAnonymousOnCert))); } } } catch (Exception ex) { TaskLogger.Trace("Exception occurred: {0}", new object[] { ex.Message }); base.WriteError(new LocalizedException(this.MetabaseGetPropertiesFailureMessage, ex), (ErrorCategory)1001, dataObject.Identity); } finally { TaskLogger.LogExit(); } return(null); }
internal bool IsAuthenticationMethodEnabled(AuthenticationMethodFlags flag) { return((this.authenticationMethods & flag) > AuthenticationMethodFlags.None); }