© 2019 by Sayantan Basu

  • Sayantan Basu

Get Users And Groups from Tridion Using Core Service API

Today I will discuss how to access the User List and Group List of Tridion using Core service API. I have already shown how to connect to the Core Service API. Today I will create a small program and access all the user and group that we have already created in our CMS.

There are several way to implement this but I am showing the simplest way to do this –

Here I have created one ASP Web Site Project and created a simple UI for the frontend. You can create a complex design as per the requirement. My design is –


As you can see here I have created 2 Link Buttons. First One “User” is used to get the list of Tridion Users. And the next one “User Group” to access the list of available groups in Tridion.

I have also used one XML(TridionItemList) to show the list on the page.

Once your core service client is ready then just use the filter to choose the type of Item you want to access from CMS. Then call the GetSystemWideListXml() method using that filter to get the list of items in XML format. You can also use GetSystemWideList() to get the result in List format. I personally prefer output in xml format because it is easier to play with xml.

Here is my code to get the List of user –

/// <summary> /// This method is called when user clicked on User link /// </summary> /// <param name=”sender”></param> /// <param name=”e”></param> protected void UserCheck_Click(object sender, EventArgs e) { CoreServiceClient _client = Utility.GetCoreServiceSettings(); // This method will return the core       service client. Check my previous blog for details. var filter = new UsersFilterData(); var UserList = _client.GetSystemWideListXml(filter); PopulateUsetList(UserList); }

So the main concept is you have to create a filter for search like –

var filter = new UsersFilterData();

Here I have created my filter of  UsersFilterData type, which will help me to access the details of User. If you want to access the Group then create a filter of GroupsFilterData type. Then call the method using core service client like –

var UserList = _client.GetSystemWideListXml(filter);

This method will return the output as a XElement item.

You can also add some more criteria to this filter like –

filter.IsPredefined = false; // Using this criteria you can get only user created User List. If you set it to true then your output will show the default( predefined ) data only. This is same for the group as well.

Next you can set the Basecolumns to ID or IdAndTitle etc.

filter.BaseColumns = ListBaseColumns.IdAndTitle;      //Using this criteria you can get only Id and Title in the output xml.

So these are like putting some extra cheese in your Pizza.  You can use these as per your requirement. Now My List is ready to Populate.

Again you can do it in several way but I am generating the List using XSLT.  Here is the code for that –

/// <summary> /// This method is called to populate the UserList /// </summary> /// <param name=”UserList”></param> private void PopulateUsetList(XElement UserList) { string myXML = UserList.ToString(); myXML = myXML.Replace(‘:’, ‘_’); TridionItemList.DocumentContent = myXML; TridionItemList.TransformSource = Server.MapPath(@”.\UserList.xslt”); }

Finally you have learned how to access the User List and Group List from Tridion CMS using core service. From here you can see the source code of this project.

Here is the final Output –


Hope you enjoy the blog. Thanks and Keep checking my blogs for future update.

#Tridion2013SP1 #TridionCoreService