2

Hi I am devolping an application with multiple sites and each site has their own extranet, and this is all working beautifully, using Sitecore 6.4.

Now I need the editors (not admins) of each site to be able to create extranet users that is only able to access the extranet connected to the site, is this even possible?

Basically I am looking for at structure like this:

Sitecore\Editor (Local extranet admin)

Extranet\user

Eimantas
  • 48,927
  • 17
  • 132
  • 168
Kenneth Jakobsen
  • 458
  • 3
  • 11

1 Answers1

0

I would think you could make an Extranet Role for each of you "extranets", eg. Site1Admin.

And then make a page that enables them to create a user, giving that user the basic roles it needs.

This is code for Sitecore 6.0, though it should be the same for 6.4 afaik:

Sitecore.Security.Accounts.User user;
if (!Sitecore.Context.IsLoggedIn)
{
    string domainUser = Sitecore.Context.Domain.GetFullName("youruser");
    string txtPassword = "yourpass";
    string txtEmail = "youremail";

    if (Sitecore.Security.Accounts.User.Exists(domainUser))
        return;

    MembershipCreateStatus status;
    Membership.CreateUser(domainUser, txtPassword, txtEmail, "Never?", "Always!", true, out status);

    if (!status.Equals(MembershipCreateStatus.Success))
    {
        throw new MembershipCreateUserException(status.ToString());
    }       
    user = //something to load the user, probably in Sitecore.Security.Accounts.User
}
    var role = "extranet\\Site1User";   

    var roles = Roles.GetRolesForUser(); //this is probably only for the current context user
    if (!roles.Contains(role))
    {
        try
        {
            Roles.AddUsersToRole(new string[] { "youruser" }, role);
        }
        catch(System.Configuration.Provider.ProviderException)
        {
            // do nothing, just move on
        }

    }
}

This is kinda simple, is based on some code I tried to hack together from some working code, that created a user and logged him in and should be adjusted to what you are doing, as there are probably some errors.

Holger
  • 2,243
  • 17
  • 19
  • I was kinda hoping to avoid this, and maybe thinking it could be done with std. functionality, but i will give this a shot. – Kenneth Jakobsen Mar 31 '11 at 07:09
  • I only think Sitecore users with a check in the Administrator or with the "Sitecore\Sitecore Client Account Managing" role. For extranet user I would assume you'd have to make some custom code that allows extranet users to create other users. Or you could try to ask Sitecore on https://support.sitecore.net/helpdesk/Default.aspx – Holger Mar 31 '11 at 07:17