示例#1
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            SecUtility.CheckArrayParameter(ref roleNames, true, true, true, 0x100, "roleNames");
            SecUtility.CheckArrayParameter(ref usernames, true, true, true, 0x100, "usernames");
            bool flag = false;

            try
            {
                SqlConnectionHolder connection = null;
                try
                {
                    connection = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true);
                    int length = usernames.Length;
                    while (length > 0)
                    {
                        string str = usernames[usernames.Length - length];
                        length--;
                        int index = usernames.Length - length;
                        while (index < usernames.Length)
                        {
                            if (((str.Length + usernames[index].Length) + 1) >= 0xfa0)
                            {
                                break;
                            }
                            str = str + "," + usernames[index];
                            length--;
                            index++;
                        }
                        int num3 = roleNames.Length;
                        while (num3 > 0)
                        {
                            string str2 = roleNames[roleNames.Length - num3];
                            num3--;
                            for (index = roleNames.Length - num3; index < roleNames.Length; index++)
                            {
                                if (((str2.Length + roleNames[index].Length) + 1) >= 0xfa0)
                                {
                                    break;
                                }
                                str2 = str2 + "," + roleNames[index];
                                num3--;
                            }
                            if (!flag && ((length > 0) || (num3 > 0)))
                            {
                                new SqlCommand("BEGIN TRANSACTION", connection.Connection).ExecuteNonQuery();
                                flag = true;
                            }
                            this.RemoveUsersFromRolesCore(connection.Connection, str, str2);
                        }
                    }
                    if (flag)
                    {
                        new SqlCommand("COMMIT TRANSACTION", connection.Connection).ExecuteNonQuery();
                        flag = false;
                    }
                }
                catch
                {
                    if (flag)
                    {
                        new SqlCommand("ROLLBACK TRANSACTION", connection.Connection).ExecuteNonQuery();
                        flag = false;
                    }
                    throw;
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.Close();
                        connection = null;
                    }
                }
            }
            catch
            {
                throw;
            }
        }
示例#2
0
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            SecUtility.CheckArrayParameter(ref roleNames, true, true, true, 256, "roleNames");
            SecUtility.CheckArrayParameter(ref usernames, true, true, true, 256, "usernames");
            bool flag = false;

            try
            {
                SqlConnectionHolder sqlConnectionHolder = null;
                try
                {
                    sqlConnectionHolder = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true);
                    int i = usernames.Length;
                    while (i > 0)
                    {
                        string text = usernames[usernames.Length - i];
                        i--;
                        int num = usernames.Length - i;
                        while (num < usernames.Length && text.Length + usernames[num].Length + 1 < 4000)
                        {
                            text = text + "," + usernames[num];
                            i--;
                            num++;
                        }
                        int j = roleNames.Length;
                        while (j > 0)
                        {
                            string text2 = roleNames[roleNames.Length - j];
                            j--;
                            num = roleNames.Length - j;
                            while (num < roleNames.Length && text2.Length + roleNames[num].Length + 1 < 4000)
                            {
                                text2 = text2 + "," + roleNames[num];
                                j--;
                                num++;
                            }
                            if (!flag && (i > 0 || j > 0))
                            {
                                new SqlCommand("BEGIN TRANSACTION", sqlConnectionHolder.Connection).ExecuteNonQuery();
                                flag = true;
                            }
                            this.RemoveUsersFromRolesCore(sqlConnectionHolder.Connection, text, text2);
                        }
                    }
                    if (flag)
                    {
                        new SqlCommand("COMMIT TRANSACTION", sqlConnectionHolder.Connection).ExecuteNonQuery();
                        flag = false;
                    }
                }
                catch
                {
                    if (flag)
                    {
                        new SqlCommand("ROLLBACK TRANSACTION", sqlConnectionHolder.Connection).ExecuteNonQuery();
                        flag = false;
                    }
                    throw;
                }
                finally
                {
                    if (sqlConnectionHolder != null)
                    {
                        sqlConnectionHolder.Close();
                        sqlConnectionHolder = null;
                    }
                }
            }
            catch
            {
                throw;
            }
        }