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?
Asked
Active
Viewed 358 times
1
-
Sorry Chris thats the problem , i cant find any help for this and i am newbie so just know how to create component and all stuff – Aquarius24 Jan 16 '13 at 12:25
1 Answers
4
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);
}
}

Peter Kjaer
- 4,316
- 13
- 23
-
Thanks for ur answer Peter I am getting this error now: ItemType' is an ambiguous reference between 'Tridion.ContentManager.ItemType' and 'Tridion.ContentManager.CoreService.Client.ItemType – Aquarius24 Jan 18 '13 at 05:58
-
Thanks Peter it worked.... Can you tell me how to get the data of a user through its Username: insted of this var user = (UserData)client.GetDefaultData(ItemType.User, null); – Aquarius24 Jan 18 '13 at 07:43
-
You can't directly load a user by its username -- you have to use the TCM URI. If you really only have the username, you will need to get a list of users first to look up the URI. If you need help with that, please enter a new question as this one is about creating new users. – Peter Kjaer Jan 18 '13 at 08:49