コード例 #1
0
ファイル: GroupProvider.cs プロジェクト: jy4618272/Common
        public static DataTable GetGroupInstancesRoles(Guid groupId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.GroupsInstancesRolesDataTable table = null;
            using (GroupsInstancesRolesTableAdapter adapter = new GroupsInstancesRolesTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                table = adapter.GetGroupsInstancesRolesByGroupId(organizationId, groupId);
            }
            table.Columns.Add("RoleName", typeof(string));

            Instance firstInstance = InstanceProvider.GetFirstInstance(organizationId);

            foreach (ClientDataSet.GroupsInstancesRolesRow row in table)
            {
                Guid roleId = row.RoleId;

                if (!FrameworkConfiguration.Current.WebApplication.EnableMultipleInstances)
                {
                    if ((roleId == RoleProvider.InstanceAdministratorRoleId) || ((firstInstance != null) && (row.InstanceId != firstInstance.InstanceId)))
                    {
                        continue;
                    }
                }

                ConfigurationDataSet.RoleRow roleRow = RoleProvider.GetRoleRow(roleId);
                if (roleRow != null)
                {
                    row["RoleName"] = roleRow.Name;
                }
            }

            return(table);
        }
コード例 #2
0
ファイル: GroupProvider.cs プロジェクト: jy4618272/Common
        public static DataTable GetGroupsInstancesRoles(List <Guid> groupIds)
        {
            if (groupIds == null)
            {
                return(null);
            }

            DataTable table = null;

            try
            {
                Guid     organizationId = UserContext.Current.OrganizationId;
                Instance firstInstance  = InstanceProvider.GetFirstInstance(organizationId);

                ClientDataSet.GroupsInstancesRolesDataTable girTable = GetGroupsInstancesRolesByGroups(organizationId, groupIds);

                table = girTable.DefaultView.ToTable(true, "GroupId", "Name");
                table.Columns.Add("ParentGroupId", typeof(Guid));
                table.Columns.Add("InstancesRoles", typeof(string));

                foreach (DataRow row in table.Rows)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (ClientDataSet.GroupsInstancesRolesRow gdrRow in girTable.Select(string.Format(CultureInfo.InvariantCulture, "{0} = '{1}'", girTable.GroupIdColumn.ColumnName, row["GroupId"])))
                    {
                        Guid roleId = gdrRow.RoleId;

                        if (!FrameworkConfiguration.Current.WebApplication.EnableMultipleInstances)
                        {
                            if ((roleId == RoleProvider.InstanceAdministratorRoleId) || ((firstInstance != null) && (gdrRow.InstanceId != firstInstance.InstanceId)))
                            {
                                continue;
                            }
                        }

                        ConfigurationDataSet.RoleRow roleRow = RoleProvider.GetRoleRow(roleId);
                        if (roleRow != null)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, ",{0} | {1}", gdrRow["InstanceName"], roleRow.Name);
                        }
                    }
                    if (sb.Length > 0)
                    {
                        sb.Remove(0, 1);
                        row["InstancesRoles"] = sb.ToString();
                    }
                }

                return(table);
            }
            finally
            {
                if (table != null)
                {
                    table.Dispose();
                }
            }
        }
コード例 #3
0
ファイル: GroupProvider.cs プロジェクト: jy4618272/Common
 internal static void DeleteInstanceAdministratorGroup(Guid organizationId)
 {
     // Looks for built-in group for the instance's administators.
     ClientDataSet.GroupsInstancesRolesDataTable table = GetGroupsInstancesRolesByRoleId(organizationId, RoleProvider.InstanceAdministratorRoleId);
     if (table.Count > 0)
     {
         DeleteGroup(table[0].GroupId);
     }
 }
コード例 #4
0
ファイル: GroupProvider.cs プロジェクト: jy4618272/Common
        public static DataTable GetGroups()
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            if (FrameworkConfiguration.Current.WebApplication.EnableMultipleInstances)
            {
                return(GetGroups(organizationId));
            }
            else
            {
                ClientDataSet.GroupDataTable table = GetGroups(organizationId);

                Instance firstInstance = InstanceProvider.GetFirstInstance(organizationId);

                if (firstInstance != null)
                {
                    ArrayList list = new ArrayList();
                    ClientDataSet.GroupsInstancesRolesDataTable girTable = null;

                    using (GroupsInstancesRolesTableAdapter adapter = new GroupsInstancesRolesTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                    {
                        girTable = adapter.GetGroupsInstancesRolesByInstanceId(organizationId, firstInstance.InstanceId);
                    }

                    foreach (ClientDataSet.GroupsInstancesRolesRow girRow in girTable)
                    {
                        if (girRow.RoleId == RoleProvider.InstanceAdministratorRoleId)
                        {
                            if (!list.Contains(girRow.GroupId))
                            {
                                list.Add(girRow.GroupId);
                            }
                        }
                    }

                    foreach (Guid groupId in list)
                    {
                        ClientDataSet.GroupRow row = table.FindByGroupId(groupId);
                        if (row != null)
                        {
                            table.RemoveGroupRow(row);
                        }
                    }

                    table.AcceptChanges();
                }

                return(table);
            }
        }
コード例 #5
0
ファイル: GroupProvider.cs プロジェクト: jy4618272/Common
        internal static Guid GetGroupInstanceRole(Guid organizationId, Guid groupId, Guid instanceId)
        {
            Guid roleId = Guid.Empty;

            using (GroupsInstancesRolesTableAdapter adapter = new GroupsInstancesRolesTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                ClientDataSet.GroupsInstancesRolesDataTable table = adapter.GetGroupsInstancesRolesByGroupIdInstanceId(organizationId, groupId, instanceId);
                if (table.Count > 0)
                {
                    roleId = table[0].RoleId;
                }
            }
            return(roleId);
        }
コード例 #6
0
ファイル: LdapIntegration.cs プロジェクト: jy4618272/Common
        public DataSet GetSortedListOfRolesGroupsById(Guid organizationId)
        {
            ClientDataSet.GroupsInstancesRolesDataTable table = GroupProvider.GetGroupsInstancesRoles(organizationId);
            table.Columns.Add("RoleName", typeof(string));
            table.Columns.Add("GroupName", typeof(string));

            foreach (ClientDataSet.GroupsInstancesRolesRow row in table.Rows)
            {
                ConfigurationDataSet.RoleRow roleRow = RoleProvider.GetRoleRow((Guid)row["RoleId"]);
                if (row != null)
                {
                    row["RoleName"] = roleRow.Name;
                }

                MasterDataSet.GroupMappingsRow[] groups = LdapInfoProvider.GetGroupMappings(organizationId).Select(string.Format(CultureInfo.InvariantCulture, "GroupId = '{0}' AND OrganizationId = '{1}'", row["GroupId"], organizationId)) as MasterDataSet.GroupMappingsRow[];
                if (groups.Length > 0)
                {
                    row["GroupName"] = groups[0].LdapGroupName;
                }
            }

            return(table.DataSet);
        }