We can access SDL Tridion User details through the UserData
object, but
can we also create Users and assign Roles using Core Services in 2011?
-
Yes - of course you can. If you have tried this and had trouble, please let us know what you tried and what the problems were.– Dominic CroninAug 13, 2013 at 6:51
Add a comment
|
1 Answer
Of course you can:
var user = (UserData) ClientAdmin.GetDefaultData(ItemType.User, null, new ReadOptions());
user.Title = "domain\\user";
user.Description = "My new user";
user.GroupMemberships = new[]
{
new GroupMembershipData
{
Group = new LinkToGroupData {IdRef = groupId},
Scope = new[]
{
new LinkWithIsEditableToRepositoryData { IdRef = publication1Id },
new LinkWithIsEditableToRepositoryData { IdRef = publication2Id },
}
},
};
user = (UserData) ClientAdmin.Create(user, new ReadOptions());