Exemplo n.º 1
0
 public static void AddDBUser(Database db, string dbusername)
 {
     // Map the user
     if (!DBChecks.DatabaseUserExists(db, dbusername))
     {
         User dbuser = new User(db, dbusername);
         dbuser.Login = dbusername;
         dbuser.Create();
         dbuser.Refresh();
     }
 }
Exemplo n.º 2
0
        public static void DropDBUser(Database sourcedb, Database destdb, string dbusername)
        {
            foreach (DatabaseRole destrole in destdb.Roles)
            {
                string       destrolename = destrole.Name;
                DatabaseRole sourcerole   = sourcedb.Roles[destrolename];

                if (!DBChecks.DBRoleExists(sourcedb, destrolename) && !sourcerole.EnumMembers().Contains(dbusername) && destrole.EnumMembers().Contains(dbusername))
                {
                    destrole.DropMember(dbusername);
                }
            }

            destdb.Users[dbusername].Drop();
        }
Exemplo n.º 3
0
        public static void AddUserToDBRoles(Database sourcedb, Database destdb, string dbusername)
        {
            foreach (DatabaseRole role in sourcedb.Roles)
            {
                if (role.EnumMembers().Contains(dbusername))
                {
                    string       rolename   = role.Name;
                    DatabaseRole destdbrole = destdb.Roles[rolename];

                    if (DBChecks.DBRoleExists(destdb, rolename) && dbusername != "dbo" && !destdbrole.EnumMembers().Contains(dbusername))
                    {
                        destdbrole.AddMember(dbusername);
                        destdbrole.Alter();
                    }
                }
            }
        }