public static string ListUserGroup(int userID) { string UsersGroups = ""; if (userID != 0) { Ektron.Cms.API.Common CommonApi = new Ektron.Cms.API.Common(); Ektron.Cms.API.User.User UserAPI = new Ektron.Cms.API.User.User(); Ektron.Cms.GroupData GroupData = new Ektron.Cms.GroupData(); //Number of Provider(" + System.Convert.ToString(UserAPI.GetUserGroupByName("Provider").GroupId) + ") Users: " + System.Convert.ToString(UserAPI.GetUserGroupByName("Provider").UserCount); Ektron.Cms.GroupData[] gData = UserAPI.GetGroupsUserIsIn(UserAPI.UserId, "GroupID"); foreach (Ektron.Cms.GroupData g in gData) { UsersGroups += g.GroupId + "',"; } } return UsersGroups; }
using Ektron.Cms; using Ektron.Cms.API; using Ektron.Cms.Common; using Ektron.Cms.Framework.Content; using Ektron.Cms.Framework.User; protected void Page_Load(object sender, EventArgs e) { #region Get User Details Ektron.Cms.CommonApi appAPI = new Ektron.Cms.CommonApi(); if (appAPI.UserId != 0) { string UserDetails = ""; Ektron.Cms.API.User.User UserAPI = new Ektron.Cms.API.User.User(); UserManager Usermanager = new UserManager(); long UserId = UserAPI.UserId; UserData Userdata = Usermanager.GetItem(UserId); if (Userdata != null) { UserDetails += "<br/><strong>UserName:</strong> " + Userdata.Username; UserDetails += "<br/><strong>User's Name:</strong> " + Userdata.FirstName + " " + Userdata.LastName; UserDetails += "<br/><strong>User's Email:</strong> " + Userdata.Email; } UserDetails += "<br/><strong>User Groups:</strong> " + ListUserGroupNames(unchecked((int)UserId)); //"<br/><strong>Username:</strong> " + LoginHelper.UserName() Response.Write(UserDetails); } #endregion Get User Details } public static string ListUserGroupNames(int userID) { string UsersGroups = ""; if (userID != 0) { Ektron.Cms.API.Common CommonApi = new Ektron.Cms.API.Common(); Ektron.Cms.API.User.User UserAPI = new Ektron.Cms.API.User.User(); Ektron.Cms.GroupData GroupData = new Ektron.Cms.GroupData(); //Number of Provider(" + System.Convert.ToString(UserAPI.GetUserGroupByName("Provider").GroupId) + ") Users: " + System.Convert.ToString(UserAPI.GetUserGroupByName("Provider").UserCount); Ektron.Cms.GroupData[] gData = UserAPI.GetGroupsUserIsIn(UserAPI.UserId, "GroupName"); foreach (Ektron.Cms.GroupData g in gData) { UsersGroups += g.GroupName + "',"; } } return UsersGroups; }
Last Updated on October 26, 2015