Aquarius24
Aquarius24

Reputation: 1866

How to create a new user in Tridion 2011 using core services?

I know how to create components, pages, structure group but i got stuck while creating new user using core services of .net? Can anyone help me out of this?

Upvotes: 1

Views: 365

Answers (1)

Peter Kjaer
Peter Kjaer

Reputation: 4316

Something like this should get you started:

public void CreateUser(string userName, string friendlyName, bool makeAdministrator)
{
    var defaultReadOptions = new ReadOptions();

    using (var client = GetCoreServiceClient())
    {
        var user = (UserData)client.GetDefaultData(ItemType.User, null);
        user.Title = userName;
        user.Description = friendlyName;
        user.Privileges = makeAdministrator ? 1 : 0;
        client.Create(user, defaultReadOptions);
    }
}

Upvotes: 4

Related Questions