Question

salut Je dépose une application avec plusieurs sites et chaque site a son propre extranet, et tout cela fonctionne bien, en utilisant SITECORE 6.4.

Maintenant, j'ai besoin des éditeurs (pas d'administrateurs) de chaque site pour pouvoir créer des utilisateurs extranet qui ne peuvent accéder à l'extranet que connecté au site, est-ce encore possible?

Fondamentalement, je cherche à la structure comme ceci:

SITECORE \ Editor (administrateur extranet local)

extranet \ utilisateur

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top