开发者

Faking User Roles in Sitecore 6.2

The Faking User Roles document in SDN appears to give exactly what I need. I have a few "roles" that I have access to through stored procedure calls I don't control, read-only, via a CRM I don't have direct access to.

Unfortunately, I can't find the method AddRole, or even the开发者_JAVA技巧 class UserItem, by its present name. Does this functionality exist in Sitecore 6.2? If so, where is it?


It seems that the code you're referencing to is for previous versions of Sitecore, I guess, 5.3.X. The security model has changed starting from 6.0 to take advantage of the ASP.NET standard security model.

In order to pull extra roles to Sitecore live from another source, you should implement an extra role provider, add it to the web.config and enable switchers. This article will give you a good overview. Just remember the general thing: Sitecore security (starting from 6.0) relies on ASP.NET security much, so what's possible in ASP.NET should be possible in Sitecore.

If one day you get the direct acccess to CRM, you should be able to use the standard Sitecore CRM security provider to obtain contacts and groups from CRM.

Hope this helps.


Without checking, I'm fairly sure your SDN reference only applies to Sitecore 5.x. The entire security model was redone in 6.x and there is no backwards compatibility.

If I understand what you want to do correctly however, your task is fairly simple. You need to create a RoleProvider, 100% per standard ASP.NET as directed on MSDN (http://msdn.microsoft.com/en-us/library/aa478950.aspx).

Next, you hook this into your Sitecore solution and configure Sitecore to "switcher" mode.

<roleManager defaultProvider="switcher" enabled="true">
<providers>
    <clear/>
    <add name="sitecore" type="Sitecore.Security.SitecoreRoleProvider, Sitecore.Kernel" realProviderName="sql" raiseEvents="true"/>
    <add name="sql" type="System.Web.Security.SqlRoleProvider" connectionStringName="core" applicationName="sitecore"/>
<add name="your" type="RoleProvider, Here" applicationName="sitecore"/>
    <add name="switcher" type="Sitecore.Security.SwitchingRoleProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/roleManager"/>
</providers>

And that's more or less it. Your roles will now appear just as any and all other roles in Sitecore, and can be assigned to users and/or roles for whatever purpose you're needing.


While those other solutions are nice, they don't answer the question.

The virtual user functionality is still alive and well in Sitecore 6, but it has moved to the AuthenticationManager class. I found it myself just as I was about to give up looking because it does address a number of limitations in the other methods.

Here's your best reference point, you'll find a good example in here.

So, how is this method useful?

It's useful when you are using multiple providers, particularly when your doing advanced Active Directory connectory type stuff.

For example, we have a situation where we authenticate users and roles against 2 different active directories, but we want to allow roles from each to be applied to the user once they log in. You'd think you could just assign roles from one AD to the user authenticated against the other AD, but of course not.. We can't directly add the 'ad' domain roles to the 'ad2' user, so we dynamically add corresponding roles from the Sitecore domain to a virtual user created under the sitecore domain. They now have access to functionality that is driven from the 'ad' domain and the 'ad2' domain.

I have a lovely little visio diagram that explains the whole thing with pretty colours, alas I cannot attach.


THis is a good question for SDN (sdn.sitecore.net). For Virtual Users, look at the AuthenticationManager class. For managing users and roles, look at Sitecore.Security.Accounts namespace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜