codeflood logo

Crestone differences update rev 080514

As is the case with beta software, Crestone is changing from release to release. I wrote my first Crestone Differences post based on the original Beta rev 080314. I recently upgrade the Crestone install which I'm testing Revolver against to rev 080514 and found some differences between this build and the previous. These differences also invalidate the code samples in my post Assessing the Everyone role in Crestone due to changes in the API.

The following is a list of the differences I found this time round.

  • There is an extra property on the User object called Delegation used to interact with the security system. Previous we could use:
Sitecore.Security.Accounts.AccountList accounts = Sitecore.Context.User.GetManagedAccounts();
  • Now we must call GetManagedAccounts through the Delegation property:
Sitecore.Security.Accounts.AccountList accounts = Sitecore.Context.User.Delegation.GetManagedAccounts();

This method now returns an IEnumerable<Sitecore.Security.Accounts.Account> where previously it returned an AccountList.

  • APIs for interacting with masters has been removed. I was a little worried in the first beta that Sitecore were going to leave all the master API calls in to provide backwards compatibility with 5.x solutions. But if the calls weren't going to do anything then the solution still wouldn't work properly. Instead you'd end up with undesirable runtime behaviors which are harder to solve than compile-time errors.

  • The "everyone" role is now called "__everyone". In the first beta it was called "##everyone".

So with the changes in the managed roles the code to assess whether a user is in the "everyone" role would now be as follows:

IEnumerable<Sitecore.Security.Accounts.Account> accounts = Sitecore.Context.User.Delegation.GetManagedAccounts();
Sitecore.Security.Accounts.Role role = Sitecore.Security.Accounts.Role.FromName("__everyone");
IEnumerator<Sitecore.Security.Accounts.Account> e = accounts.GetEnumerator();
while (e.MoveNext())
{
  if(role.IsMember(e.Current, true, true))
  {
    // User is in this role. Do Something
  }
}

It's hard to predict if there will be any more changes when Crestone is officially released at the end of this month. I've read that Sitecore are in polish mode at the moment, which is what I'd expect. But that polish may include removing old APIs. Best to allow at this stage for some rework. We'll just have to wait and see.

Comments

Leave a comment

All fields are required.