Ektron API – GetUserGroup

| | |
public static int GetUserGroup(int userID, string GroupID)
	{
		int inGroup = 0;
		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("<GROUP NAME>").GroupId) + ") Users: " + System.Convert.ToString(UserAPI.GetUserGroupByName("<GROUP NAME>").UserCount);
				Ektron.Cms.GroupData[] gData = UserAPI.GetGroupsUserIsIn(UserAPI.UserId, "GroupID");
				foreach (Ektron.Cms.GroupData g in gData)
					{
						UsersGroups += g.GroupId + "',";
					}
				string[] strGroupIDs = UsersGroups.Split(',');
				foreach (string strGroupID in strGroupIDs)
					{
						if (GroupID == strGroupID)
							{
								inGroup = 1;
							}
						if (strGroupID == "1")
							{
								inGroup = 2;
							}
					}
			}
		return inGroup;
	}
Originally Posted on February 21, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.