Last active
February 24, 2016 18:19
-
-
Save justsayantan/f0f16e20e95cffc7f7dc to your computer and use it in GitHub Desktop.
Get User List and Group List for Tridion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" %> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<h2> | |
Welcome to My Tridion Custome Site | |
</h2> | |
<p> Check the User & Group in Tridion </p> | |
<table> | |
<tr> | |
<td> | |
<div> | |
<asp:LinkButton ID="UserCheck" runat="server" onclick="UserCheck_Click">User</asp:LinkButton> | |
| |
<asp:LinkButton ID="UserGroupCheck" runat="server" | |
onclick="UserGroupCheck_Click">User Group</asp:LinkButton> | |
</div> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<div> | |
<asp:Xml ID="TridionItemList" runat="server"></asp:Xml> | |
</div> | |
</td> | |
</tr> | |
</table> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
using System.Collections.Generic; | |
using Tridion.ContentManager.CoreService.Client; | |
using System.ServiceModel; | |
using System.Runtime.Serialization; | |
using Tridion.Logging; | |
using System.Diagnostics; | |
using System.Configuration; | |
using System.Net; | |
using System.Collections; | |
using System.IO; | |
using System.Data; | |
using System.ComponentModel; | |
using System.Text; | |
using System.Xml; | |
using System.Xml.Linq; | |
namespace PracticeApplication | |
{ | |
public partial class Admin : System.Web.UI.Page | |
{ | |
/// <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(); | |
var filter = new UsersFilterData(); | |
filter.IsPredefined = false; | |
filter.BaseColumns = ListBaseColumns.IdAndTitle; | |
var UserList = _client.GetSystemWideListXml(filter); | |
PopulateUsetList(UserList); | |
} | |
/// <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"); | |
} | |
/// <summary> | |
/// This method is called when user clicked on User Group link | |
/// </summary> | |
/// <param name="sender"></param> | |
/// <param name="e"></param> | |
protected void UserGroupCheck_Click(object sender, EventArgs e) | |
{ | |
CoreServiceClient _client = Utility.GetCoreServiceSettings(); | |
var filter = new GroupsFilterData(); | |
//filter.IsPredefined = false; // Make it false if you want to show the deta the default group as well. Otherwise make it true. | |
//filter.BaseColumns = ListBaseColumns.IdAndTitle; // This is used to get only ID and Title as a result | |
var GroupList = _client.GetSystemWideListXml(filter); | |
PopulateGroupList(GroupList); | |
} | |
/// <summary> | |
/// This method is called to populate the User Group List | |
/// </summary> | |
/// <param name="GroupList"></param> | |
private void PopulateGroupList(XElement GroupList) | |
{ | |
string myXML = GroupList.ToString(); | |
myXML = myXML.Replace(':', '_'); | |
TridionItemList.DocumentContent = myXML; | |
TridionItemList.TransformSource = Server.MapPath(@".\TridionUserGroup.xslt"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" | |
> | |
<xsl:output method="html" indent="yes"/> | |
<xsl:template match="/"> | |
<table width="500px" border="1px" style="text-align:left;border-collapse:collapse"> | |
<tr backcolor="blue"> | |
<td> | |
<strong>Title</strong> | |
</td> | |
<td> | |
<strong> | |
Description | |
</strong> | |
</td> | |
<td> | |
<strong> | |
IsEnabled | |
</strong> | |
</td> | |
<td> | |
<strong> | |
Type Of Group | |
</strong> | |
</td> | |
</tr> | |
<xsl:for-each select="tcm_ListTrustees/tcm_Item"> | |
<tr> | |
<td> | |
<xsl:value-of select="@Title"/> | |
</td> | |
<td> | |
<xsl:value-of select="@Description"/> | |
</td> | |
<td> | |
<xsl:variable name="IsEnabled" select="@Enabled"/> | |
<xsl:if test="$IsEnabled > 0"> | |
Enable | |
</xsl:if> | |
<xsl:if test="$IsEnabled = 0"> | |
Dissable | |
</xsl:if> | |
</td> | |
<td> | |
<xsl:variable name="isPredefined" select="@IsPredefined"/> | |
<xsl:if test="$isPredefined = 'true'"> | |
Default Group | |
</xsl:if> | |
<xsl:if test="$isPredefined = 'false'"> | |
User Created Group | |
</xsl:if> | |
</td> | |
</tr> | |
</xsl:for-each> | |
</table> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" | |
> | |
<xsl:output method="html" indent="yes"/> | |
<xsl:template match="/"> | |
<table width="500px" border="1px" style="text-align:left;border-collapse:collapse"> | |
<tr backcolor="blue"> | |
<td> | |
<strong>Title</strong> | |
</td> | |
<td> | |
<strong> | |
Description | |
</strong> | |
</td> | |
<td> | |
<strong> | |
IsEnabled | |
</strong> | |
</td> | |
</tr> | |
<xsl:for-each select="tcm_ListTrustees/tcm_Item"> | |
<tr> | |
<td> | |
<xsl:value-of select="@Title"/> | |
</td> | |
<td> | |
<xsl:value-of select="@Description"/> | |
</td> | |
<td> | |
<xsl:variable name="IsEnabled" select="@Enabled"/> | |
<xsl:if test="$IsEnabled > 0"> | |
Enable | |
</xsl:if> | |
<xsl:if test="$IsEnabled = 0"> | |
Dissable | |
</xsl:if> | |
</td> | |
</tr> | |
</xsl:for-each> | |
</table> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using Tridion.ContentManager.CoreService.Client; | |
using System.ServiceModel; | |
using System.Runtime.Serialization; | |
using Tridion.Logging; | |
using System.Diagnostics; | |
using System.Configuration; | |
using System.Net; | |
using System.Collections; | |
using System.IO; | |
using System.Data; | |
using System.ComponentModel; | |
using System.Text; | |
using System.Xml; | |
using System.Xml.Linq; | |
namespace PracticeApplication | |
{ | |
public static class Utility | |
{ | |
/// <summary> | |
/// Core service client configuration | |
/// </summary> | |
/// <returns>return the client detail</returns> | |
public static CoreServiceClient GetCoreServiceSettings() | |
{ | |
var binding = new NetTcpBinding | |
{ | |
MaxReceivedMessageSize = 2147483647, | |
ReaderQuotas = new XmlDictionaryReaderQuotas | |
{ | |
MaxStringContentLength = 2147483647, | |
MaxArrayLength = 2147483647 | |
} | |
}; | |
var endpoint = new EndpointAddress("net.tcp://localhost:2660/CoreService/2013/netTcp"); | |
var client = new CoreServiceClient(binding, endpoint); | |
client.ChannelFactory.Credentials.Windows.ClientCredential = new NetworkCredential("adminid", "password"); | |
return client; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment