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).

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

2 Answers 2

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#.

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.

7
  • 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. Sep 14, 2015 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. Jan 19, 2016 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. Jan 19, 2016 at 15:49
  • Excellent!! I was looking for this.. Many many many thanks Peter Jan 20, 2016 at 12:52
  • You're most welcome! Glad to hear it helped you out :) Jan 20, 2016 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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