Search code examples
sitefinityroleprovider

what are Provider Abilities with Custom Role Providers in Sitefinity


I'm trying to implement a custom role provider in sitefinity. I've found a few examples but I can't find anything that's documented that well. One of the things I'd like to know more about is what options are available in the Provider Abilities array.

I see an example from git hub that lists some of them, but what else is available to put in there? The provider I'm creating will be a read-only provider so I'd like to know what else I can put in there and mark it as either not supported or not allowed.

What other options are available?

example from git hub


Solution

  • You use this to basically say what actions your provider supports.

    The built-in OpenAccessRoleProvider provider (the one that uses the database to store roles) supports all those actions (add/remove/get role, assign/unassign user to role) that you attached, but the LdapRoleProvider for instance, does not support the DeleteRole ability (note how its second and third params are false):

    LdapRoleProvider:

    public override ProviderAbilities Abilities
        {
            get
            {
                ProviderAbilities providerAbility = new ProviderAbilities()
                {
                    ProviderName = this.Name,
                    ProviderType = base.GetType().FullName
                };
                providerAbility.AddAbility("GetRole", true, true);
                providerAbility.AddAbility("AddRole", false, false);
                providerAbility.AddAbility("AssingUserToRole", false, false);
                providerAbility.AddAbility("UnAssingUserFromRole", false, false);
                providerAbility.AddAbility("DeleteRole", false, false);
                return providerAbility;
            }
        }
    
    public void AddAbility(string operationName, bool supported, bool allowed) {...}
    

    That's normal - for instance you cannot delete a role in the Active Directory from Sitefinity.