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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top