예제 #1
0
		public UserSchema (UserSchema user)
			: base (user)
		{
			this.userId = user.userId;
			this.password = user.password;
			this.expires = user.expires;
		}
        public override UserSchemaCollection GetUsers()
        {
            UserSchemaCollection users = new UserSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand("SELECT DISTINCT user from mysql.user where user != '';");

            try {
                using (command) {
                    using (IDataReader r = command.ExecuteReader()) {
                        while (r.Read())
                        {
                            UserSchema user = new UserSchema(this);
                            user.Name = r.GetString(0);

                            users.Add(user);
                        }

                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(users);
        }
        public virtual UserSchema GetNewUserSchema(string name)
        {
            UserSchema schema = new UserSchema(this);

            schema.Name = name;
            return(schema);
        }
예제 #4
0
 public UserSchema(UserSchema user)
     : base(user)
 {
     this.userId   = user.userId;
     this.password = user.password;
     this.expires  = user.expires;
 }
        protected virtual UserSchema GetUser(DataRow row)
        {
            UserSchema schema = new UserSchema(this);

            schema.Name = GetRowString(row, userItemStrings[0]);
            return(schema);
        }
        public override UserSchemaCollection GetUsers()
        {
            UserSchemaCollection users = new UserSchemaCollection();

            IPooledDbConnection conn    = connectionPool.Request();
            IDbCommand          command = conn.CreateCommand("SELECT * FROM pg_user;");

            try {
                using (command) {
                    using (IDataReader r = command.ExecuteReader()) {
                        while (r.Read())
                        {
                            UserSchema user = new UserSchema(this);

                            user.Name    = r.GetString(0);
                            user.UserId  = String.Format("{0}", r.GetValue(1));
                            user.Expires = r.IsDBNull(6) ? DateTime.MinValue : r.GetDateTime(6);
                            //user.Options["createdb"] = r.GetBoolean (2);
                            //user.Options["createuser"] = r.GetBoolean (3);
                            user.Password = r.GetString(5);

                            StringBuilder sb = new StringBuilder();
                            sb.AppendFormat("-- User: \"{0}\"\n\n", user.Name);
                            sb.AppendFormat("-- DROP USER {0};\n\n", user.Name);
                            sb.AppendFormat("CREATE USER {0}", user.Name);
                            sb.AppendFormat("  WITH SYSID {0}", user.UserId);
                            if (user.Password != "********")
                            {
                                sb.AppendFormat(" ENCRYPTED PASSWORD {0}", user.Password);
                            }
                            //sb.AppendFormat (((bool) user.Options["createdb"]) ?
                            //	" CREATEDB" : " NOCREATEDB");
                            //sb.AppendFormat (((bool) user.Options["createuser"]) ?
                            //	" CREATEUSER" : " NOCREATEUSER");
                            if (user.Expires != DateTime.MinValue)
                            {
                                sb.AppendFormat(" VALID UNTIL {0}", user.Expires);
                            }
                            sb.Append(";");
                            user.Definition = sb.ToString();

                            users.Add(user);
                        }
                        r.Close();
                    }
                }
            } catch (Exception e) {
                QueryService.RaiseException(e);
            }
            conn.Release();

            return(users);
        }
예제 #7
0
        public override ICollection <UserSchema> GetUsers()
        {
            CheckConnectionState();
            List <UserSchema> users = new List <UserSchema> ();

            IDbCommand command = connectionProvider.CreateCommand("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES;");

            using (command) {
                using (IDataReader r = command.ExecuteReader()) {
                    while (r.Read())
                    {
                        UserSchema user = new UserSchema(this);
                        user.Name = r.GetString(0);
                        users.Add(user);
                    }
                    r.Close();
                }
                connectionProvider.Close(command.Connection);
            }

            return(users);
        }
예제 #8
0
		public UserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create)
		{
			this.Build();
			
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			if (user == null)
				throw new ArgumentNullException ("user");
			
			this.schemaProvider = schemaProvider;
			this.user = user;
			this.action = create ? SchemaActions.Create : SchemaActions.Alter;
			
			this.Build();
			
			if (create)
				Title = GettextCatalog.GetString ("Create User");
			else
				Title = GettextCatalog.GetString ("Alter User");
			
			notebook = new Notebook ();
			vboxContent.PackStart (notebook, true, true, 0);
			vboxContent.ShowAll ();
		}
		protected virtual UserSchema GetUser (DataRow row)
		{
			UserSchema schema = new UserSchema (this);
			schema.Name = GetRowString (row, userItemStrings[0]);
			return schema;
		}
예제 #10
0
		public UserNode (DatabaseConnectionContext context, UserSchema user)
			: base (context)
		{
			if (user == null)
				throw new ArgumentNullException ("user");
			
			this.user = user;
		}
예제 #11
0
 public bool ShowUserEditorDialog(ISchemaProvider schemaProvider, UserSchema user, bool create)
 {
     return(RunDialog(new UserEditorDialog(schemaProvider, user, create)));
 }
		public override ICollection<UserSchema> GetUsers ()
		{
			CheckConnectionState ();
			List<UserSchema> users = new List<UserSchema> ();

			IDbCommand command = connectionProvider.CreateCommand ("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES;");
			using (command) {
				using (IDataReader r = command.ExecuteReader ()) {
					while (r.Read ()) {
						UserSchema user = new UserSchema (this);
						user.Name = r.GetString (0);
						users.Add (user);
					}
					r.Close ();
				}
				connectionProvider.Close (command.Connection);
			}

			return users;
		public bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create)
		{
			return RunDialog (new UserEditorDialog (schemaProvider, user, create));
		//http://www.postgresql.org/docs/8.2/interactive/sql-alteruser.html
		public override void AlterUser (UserSchema user)
		{
			throw new NotImplementedException ();
		//http://www.postgresql.org/docs/8.2/interactive/sql-dropuser.html
		public override void DropUser (UserSchema user)
		{
			ExecuteNonQuery ("DROP USER IF EXISTS " + user.Name + ";");
		//http://www.postgresql.org/docs/8.2/interactive/sql-alteruser.html
		public override void RenameUser (UserSchema user, string name)
		{
			ExecuteNonQuery ("ALTER USER " + user.Name + " RENAME TO " + name + ";");
			
			user.Name = name;
 public virtual void DropUser(UserSchema user)
 {
     throw new NotImplementedException();
 }
        //http://www.postgresql.org/docs/8.2/interactive/sql-alteruser.html
        public override void RenameUser(UserSchema user, string name)
        {
            ExecuteNonQuery("ALTER USER " + user.Name + " RENAME TO " + name + ";");

            user.Name = name;
        }
 //http://www.postgresql.org/docs/8.2/interactive/sql-dropuser.html
 public override void DropUser(UserSchema user)
 {
     ExecuteNonQuery("DROP USER IF EXISTS " + user.Name + ";");
 }
 public virtual void RenameUser(UserSchema user, string name)
 {
     throw new NotImplementedException();
 }
		public virtual void DropUser (UserSchema user)
		{
			throw new NotImplementedException ();
		}
		public virtual void RenameUser (UserSchema user, string name)
		{
			throw new NotImplementedException ();
		}
		public virtual UserSchema GetNewUserSchema (string name)
		{
			UserSchema schema = new UserSchema (this);
			schema.Name = name;
			return schema;
		}
예제 #24
0
 public override void AlterUser(UserSchema user)
 {
     throw new NotImplementedException();
 }
		public override UserSchemaCollection GetUsers ()
		{
			UserSchemaCollection users = new UserSchemaCollection ();

			IPooledDbConnection conn = connectionPool.Request ();
			IDbCommand command = conn.CreateCommand ("SELECT * FROM pg_user;");

			try {
				using (command) {
					using (IDataReader r = command.ExecuteReader ()) {
						while (r.Read ()) {
							UserSchema user = new UserSchema (this);
							
							user.Name = r.GetString (0);
							user.UserId = String.Format ("{0}", r.GetValue (1));
							user.Expires = r.IsDBNull (6) ? DateTime.MinValue : r.GetDateTime (6);
							//user.Options["createdb"] = r.GetBoolean (2);
							//user.Options["createuser"] = r.GetBoolean (3);
							user.Password = r.GetString (5);
							
							StringBuilder sb = new StringBuilder ();
							sb.AppendFormat ("-- User: \"{0}\"\n\n", user.Name);
							sb.AppendFormat ("-- DROP USER {0};\n\n", user.Name);
							sb.AppendFormat ("CREATE USER {0}", user.Name);
							sb.AppendFormat ("  WITH SYSID {0}", user.UserId);
							if (user.Password != "********")
								sb.AppendFormat (" ENCRYPTED PASSWORD {0}", user.Password);
							//sb.AppendFormat (((bool) user.Options["createdb"]) ?
							//	" CREATEDB" : " NOCREATEDB");
							//sb.AppendFormat (((bool) user.Options["createuser"]) ?
							//	" CREATEUSER" : " NOCREATEUSER");
							if (user.Expires != DateTime.MinValue)
								sb.AppendFormat (" VALID UNTIL {0}", user.Expires);
							sb.Append (";");
							user.Definition = sb.ToString ();
		
							users.Add (user);
						}
						r.Close ();
					}
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();

			return users;