/// <summary> /// Returns an object populated with information of the role that the group has in the instance. /// </summary> /// <param name="organizationId">The unique identifier of the organization.</param> /// <param name="groupId">The unique identifier of the group.</param> /// <param name="instanceId">The unique identifier of the instance.</param> /// <returns></returns> public static ConfigurationDataSet.RoleRow GetRoleRow(Guid organizationId, Guid groupId, Guid instanceId) { Guid roleId = GroupProvider.GetGroupInstanceRole(organizationId, groupId, instanceId); if (roleId != Guid.Empty) { return(GetRoleRow(roleId)); } return(null); }
private static SortedList GetGroupInstanceActionIdListFromCache(Guid organizationId, Guid groupId, Guid instanceId) { string key = string.Format(CultureInfo.InvariantCulture, GroupInstanceActionIdListKeyFormat, groupId, instanceId); SortedList list = CacheManager.Current.Get(key, true) as SortedList; if (list == null) { lock (s_GroupInstanceActionIdListSyncRoot) { list = CacheManager.Current.Get(key) as SortedList; if (list == null) { list = new SortedList(); // Overrides the access to the actions by the values for the group in the instance. foreach (ClientDataSet.GroupsInstancesActionsRow actionRow in GroupProvider.GetGroupsInstancesActionsByGroupIdInstanceId(organizationId, groupId, instanceId)) { if (list.Contains(actionRow.ActionId)) { list[actionRow.ActionId] = actionRow.Enabled; } else { list.Add(actionRow.ActionId, actionRow.Enabled); } } CacheManager.Current.PutWithDefaultTimeout(key, list); } } } if (list != null) { return((SortedList)list.Clone()); } return(list); }
public static void ImportUser(UserEntry userEntry, Guid organizationId, string domain) { if (userEntry != null) { Guid instanceId = InstanceProvider.GetFirstInstanceId(organizationId); SortedList list = GroupProvider.GetGroupIdRoleIdList(organizationId, instanceId); Guid groupId = GroupProvider.GetGroupIdOfLowestRoleInInstance(list); string groups = groupId.ToString(); if (userEntry.Login.Admin) { groups = Guid.Empty.ToString(); System.Collections.IList roleIdList = list.GetValueList(); if (roleIdList != null) { Guid roleId = RoleProvider.GetHighestNonBuiltInRoleId(roleIdList); if (roleId != Guid.Empty) { int idx = list.IndexOfValue(roleId); if (idx > -1) { groupId = (Guid)list.GetKey(idx); groups = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", groups, groupId.ToString()); } } roleId = RoleProvider.GetHighestBuiltInRoleId(roleIdList); if (roleId != Guid.Empty) { int idx = list.IndexOfValue(roleId); if (idx > -1) { groupId = (Guid)list.GetKey(idx); groups = string.Format(CultureInfo.InvariantCulture, "{0}, {1}", groups, groupId.ToString()); } } } } string loginName = string.Format(CultureInfo.InvariantCulture, "{0}@{1}", userEntry.Login.UserName, domain); string password = null; var drv = LoginProvider.Current.GetLogin(loginName); if (drv == null) { password = LoginProvider.Current.GeneratePassword(); } Guid loginId = UserProvider.AddUserToOrganization(loginName, userEntry.Name.GivenName, userEntry.Name.FamilyName, null , null, null, null, null, null , null, null, null, null, null, null , groups, organizationId , password, false, !string.IsNullOrEmpty(password)); if (string.IsNullOrEmpty(password)) { UserProvider.RaiseUserUpdated(loginId, organizationId, Support.ConvertStringToGuidList(groups), loginName); } else { UserProvider.RaiseUserInserted(loginId, organizationId, null, Support.ConvertStringToGuidList(groups)); } } }