[Mono-dev] [PATCH] ActiveDirectoryMembershipProvider

joel reed joelwreed at gmail.com
Wed Apr 4 10:27:24 EDT 2007


By the way, here's what the exception looks like without this change:

System.TypeInitializationException: An exception was thrown by the type 
initializer for System.Web.Security.Membership ---> 
System.ArgumentNullException: Argument cannot be null.
   at System.Configuration.Provider.ProviderCollection.Add 
(System.Configuration.Provider.ProviderBase provider) [0x00000]
   at System.Web.Security.MembershipProviderCollection.Add 
(System.Configuration.Provider.ProviderBase provider) [0x00000]
   at System.Web.Configuration.ProvidersHelper.InstantiateProviders 
(System.Configuration.ProviderSettingsCollection configProviders, 
System.Configuration.Provider.ProviderCollection providers, System.Type 
providerType) [0x00000]
   at System.Web.Security.Membership..cctor () [0x00000] --- End of 
inner exception stack trace ---

jr

joel reed wrote:
> The patch below enhances the usefulness of 
> ActiveDirectoryMembershipProvider under mono, but may not be acceptable 
> for inclusion in svn. I'm posting this in case some one else runs into a 
> similar problem as I encountered.
> 
> We have a Membership Provider that derives from 
> ActiveDirectoryMembershipProvider and then overrides Initialize and 
> ValidateUser. Our ValidateUser method looks in web.config and either 
> does an validation against AD or our legacy authentication scheme.
> 
> This works on mono (if configured to not use AD), as long as the 
> Initialize method in ActiveDirectoryMembershipProvider calls 
> base.Initialize. Calling base.Initialize is important as this is how 
> ProviderBase sets the Name property which lets the Provider be put into 
> a ProviderCollection. Without the Name, Adding the provider to the 
> collection fails with a ArgumentNullException.
> 
> Currently ActiveDirectoryMembershipProvider just does a "throw 
> NotImplemented".
> 
> If instead we said:
> 
> mcs/class/System.Web/System.Web.Security/ActiveDirectoryMembershipProvider.cs.orig 
> 2007-04-03 20:59:32.000000000 -0400
> +++ 
> mcs/class/System.Web/System.Web.Security/ActiveDirectoryMembershipProvider.cs 
> 2007-04-03 20:59:50.000000000 -0400
> @@ -118,7 +118,7 @@ namespace System.Web.Security {
>          [MonoTODO("Not implemented")]
>          public override void Initialize (string name, 
> NameValueCollection config)
>          {
> -            throw new NotImplementedException ();
> +            base.Initialize(name, config);
>          }
>         
>          [MonoTODO("Not implemented")]
> 
> The class would be slightly more useful in the above scenario. Probably 
> this circumvents some policy about MonoTODOs, but again just want to 
> post this info somewhere for others to google. It might even improve 
> things just by calling base.Initialize and then throwing, as you could 
> catch that exception and still be in business. Thoughts?
> 
> jr
> 



More information about the Mono-devel-list mailing list