Esempio n. 1
0
 public bool Compare(User obj)
 {
     if (obj == null) throw new ArgumentNullException("destino");
     if (!this.Login.Equals(obj.Login)) return false;
     if (!this.Owner.Equals(obj.Owner)) return false;
     return true;
 }
Esempio n. 2
0
 public void Fill(Database database, string connectioString)
 {
     string type;
     if ((database.Options.Ignore.FilterUsers) || (database.Options.Ignore.FilterRoles))
     {
         using (SqlConnection conn = new SqlConnection(connectioString))
         {
             using (SqlCommand command = new SqlCommand(UserSQLCommand.Get(database.Info.Version), conn))
             {
                 conn.Open();
                 command.CommandTimeout = 0;
                 using (SqlDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         type = reader["type"].ToString();
                         if (database.Options.Ignore.FilterUsers && (type.Equals("S") || type.Equals("U")))
                         {
                             User item = new User(database);
                             item.Id = (int)reader["principal_id"];
                             item.Name = reader["name"].ToString();
                             item.Login = reader["Login"].ToString();
                             item.Owner = reader["default_schema_name"].ToString();
                             database.Users.Add(item);
                         }
                         if (database.Options.Ignore.FilterRoles && (type.Equals("A") || type.Equals("R")))
                         {
                             Role item = new Role(database);
                             item.Id = (int)reader["principal_id"];
                             item.Name = reader["name"].ToString();
                             item.Owner = reader["default_schema_name"].ToString();
                             item.Password = "";
                             item.IsSystem = (Boolean)reader["is_fixed_role"];
                             if (type.Equals("A"))
                                 item.Type = Role.RoleTypeEnum.ApplicationRole;
                             else
                                 item.Type = Role.RoleTypeEnum.DatabaseRole;
                             database.Roles.Add(item);
                         }
                     }
                 }
             }
         }
     }
 }