Membership Provider by API

Posted by natabc23 on 07-Nov-2019 14:58

Hi,

  We are working with Membership Provider based as the Default Provider. We need to create by API, the membership provider with the same type as a Default Provider but another name. Can anyone help us?

All Replies

Posted by jread on 11-Nov-2019 14:21

You want to create the new Provider via code or you want the interface you need to write your own custom memebership provider?

Posted by natabc23 on 12-Nov-2019 14:43

We want to create a new Provider via code

Posted by jread on 12-Nov-2019 19:29

Here is the documentation to create a custom membership provider.  This will allow you to control how the provider functions and where it is stored.  www.progress.com/.../tutorial-create-a-custom-membership-provider

Posted by jread on 12-Nov-2019 19:29

Here is the documentation to create a custom membership provider.  This will allow you to control how the provider functions and where it is stored.  www.progress.com/.../tutorial-create-a-custom-membership-provider

Posted by natabc23 on 11-Dec-2019 20:07

But this information create a new membership provider complete. I need create one but the type "Telerik.Sitefinity.Security.Data.OpenAccessMembershipProvider, Telerik.Sitefinity"

Posted by jread on 13-Dec-2019 12:45

I see what you are asking now, sorry I misunderstood your request. Below you will find an example of working with the SecurityConfig (memebership providers) below. 

ConfigManager manager = ConfigManager.GetManager();//Get the config manager to work with the configurations
			using (ElevatedModeRegion elevatedModeRegion = new ElevatedModeRegion(manager))//Use this if you are running it during app bootstrap 
			{
				SecurityConfig config = manager.GetSection<SecurityConfig>(); //Get the configuration file
				string name = "TestApi2"; //Set a name (unique) for the provider
				if (!config.MembershipProviders.ContainsKey(name)) //confirm it does not exist
				{
					Type providerType = typeof(Telerik.Sitefinity.Security.Data.OpenAccessMembershipProvider); //Get the provider type
					string providerTypeName = $"{providerType.FullName}, {providerType.Assembly.FullName}"; //Build the providertype name
					DataProviderSettings setting = new DataProviderSettings(config.MembershipProviders)//Build the provider setting to insert
					{
						ProviderTypeName = providerTypeName,
						Name = name
					};

					config.MembershipProviders.Add(setting);//Add it to the membership provider setting
					manager.SaveSection(config); //save the configuration
				}
			}

Posted by natabc23 on 18-Dec-2019 15:04

Thanks!

This worked for me.

Posted by natabc23 on 18-Dec-2019 15:05

Thanks!

This worked for me.

This thread is closed