2

I am trying to automate few daily tasks for some of Tridion admins. We have 800+ publications 600+ users and more than 1000 groups. So, I am trying to automate user creation. Recently we have migrated from 2009 version, where I used COM+ to achieve this, but that code is not working anymore on 2013. I want to use core service, hence would be great if some sample project is available. I am using C# (4.0 framework).

  • Have you evaluated the option to migrate the users and groups from 2009 to 2013? – Hiren Kaku Sep 10 '15 at 19:12
  • The migration of exiting users are already done. What I am asking is for new user creation. – Sankar Sengupta Sep 14 '15 at 10:25
1

My blog post on Setting Rights and Permissions has example code in Powershell which includes creating users and adding groups to them. It should be straightforward enough to implement similar logic in C#.

| improve this answer | |
1

I assume you are talking about user creation that isn't covered already by synchronization with Active Directory and other such features available out-of-the-box.

To create a user using the Core Service is fairly straight-forward. It involves these steps:

  1. Create a new SessionAwareCoreServiceClient.
  2. Call GetDefaultData on the client and pass in ItemType.User as the first parameter. This will give you a UserData object with all of the default data filled in.
  3. Set the properties you care about, such as Title, Description, Privileges, etc.
  4. Save the user by calling Create on the client and passing in the user object.

The only sample code I have for this is the Tridion PowerShell Modules project I wrote. Perhaps it is still useful for you? If so, have a look at the New-User function in Trustees.ps1. You could even use these modules to automate it, if you know how to use PowerShell.

Also, be sure to download the Core Service API documentation from the 2013 SP1 documentation.

| improve this answer | |
  • Hi Peter, thanks a lot. I am not very comfortable at using Powershell. I have a website built in the same location where Tridion CMS is hosted. So basically the main URL is same, but I am using a different location to host my website. I have a list of AD accounts who can use it but I also want to impersonate all activities via one account already in CMS as ADMIN. – Sankar Sengupta Sep 14 '15 at 10:29
  • Hi Peter, I saw the powershell implementation and tried to use it in C#. I am having few problems. The major problem is how I can set up the new user to be added to a group and then set the publication scope. The GroupMembershipData object has Group and Scope both. Group is of LinkToGroupData object type, where I can define two main stuff, an Id Ref (TCM ID), a Title. At the moment I am unable set them as the way powershell code is done in C#. Any help would be very much appreciated. – Sankar Sengupta Jan 19 '16 at 13:54
  • I would have to see the code to know what is going wrong. But have a look at the following answer: tridion.stackexchange.com/a/2995/141 If you still cannot get it to work, perhaps you could ask a new question specific to how you add group memberships to users/groups? And include the code you wrote so we can help troubleshoot it. – Peter Kjaer Jan 19 '16 at 15:49
  • Excellent!! I was looking for this.. Many many many thanks Peter – Sankar Sengupta Jan 20 '16 at 12:52
  • You're most welcome! Glad to hear it helped you out :) – Peter Kjaer Jan 20 '16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.