Creating a user in Postgres Database - c#

Unable to create role when i connect using npgsql. Authorisation error.
I tried to GRANT ALL on rolesTable to ascertain if that would make a difference but same error.
CREATE ROLE roleName LOGIN ENCRYPTED PASSWORD ##### VALID UNTIL 'infinity' CONNECTION LIMIT 3
I thought the role would be created but instead I get 42501:permission denied to create role. The strange thing when I login to the postgres database using the user using PgAdmin tool I can create a user by the GUI.

Related

Authentication issue with C# connection to mysql

So I have an application that is trying to use Command.ExecuteScalar, which works perfectly well on a connection with "root" credentials or with my own user credentials, but I have set up another user in workbench called "AgentsHighPriv" and with that it fails.
The connectionstring is the same except for the substitution with the alternative username and password. However this username and password connects in MySql Workbench, what am I overlooking here.
The specific error message is:
{"Authentication to host 'xxxx' for user 'AgentsHighPriv' using method 'mysql_native_password' failed with message: Access denied for user 'AgentsHighPriv'#'%' to database 'rbac'"}
Well it seems there is a difference between credentials that I had not grasped. The privileges had some differences; "schema privalges" were the same as for my own user privileges but, the New User did not require admin privileges of any kind, so I did not use the tab and set global privileges. However if on the administrative roles tab I actually select one of the global privalages, - it then authenticates. At least to say it did so when I tested with select, show view, alter, and drop
Yet I have these same privalages set on the Schema Privalages tab!
So this will make it work now but I dont understand the logic - if anybody could explain I would be happy to hear.
Thanks

"Access denied for user 'test'#'%' to database 'test'

I have been trying to access the remote MySql database server in C# Entity framework but end in following error
{"Access denied for user 'test'#'%' to database 'test'"}
My connection string is server='192.168.0.1';uid=test;database=test;password=1234
However if i access the database through workbench it allows me to access the server and inserting and deleting the data in tables.
What causing the error ?
Execute below statement to grant access on test-
GRANT all privileges on test.* to test#'%' identified by '1234';
Note: You can change all privileges with your specific permissions.
You can also assign rights on all databases by-
GRANT all privileges on *.* to test#'%' identified by '1234';
Note: Best way is that rights should provide only to specific ip and limited rights as per requirement.

Error in trying to create new Firebird user using Firebird client in C#

I'm trying to create new DB user for Firebird 2.5 DB from my C# application and geting an error "add record error no permission for insert/write access to TABLE USERS".
I've granted rdb$admin role to the user, created connection to DB using this role yet still i'm getting this error.
Wierdiest thing for me is that when i'm trying to create new user for my DB in IBExpert using same user settings and role (rdb$admin) it goes fine and I don't get eny errors.
What could be the problem? Why can't I execute SQL queries and procedures that update/insert in USERS table although I have appropriate role, that I'm using establishing connection?
I'm using latest FirebirdClient - ADO.NET Data Provider.
Connection string to the DB looks like this:
`"User=developer;Password=*****;Database=C:\DB.fdb;DataSource=*****;Port=*****;Dialect=3;Charset=NONE;Role=rdb$admin;Connection lifetime=15;Pooling=True;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0;"`
Can somebody help me with this problem?
I've found a solution - problem was that I forgot to GRANT ADMIN ROLE to the user by which I've executed procedure so I can't manage database users.
So GRANT ADMIN ROLE to user solved the problem.

Granting table level permissions in sql express 2005

I created a login to connect to SQL SERVER.
create login bobLogin with password = 'bobpass' , default_database = bobDB
but when i am connecting sql server using this, it does not connects? because it needs a user.
so i created a user:
create user bobDB_USER for login bobLogin
then i connected to sql server using bobLogin & tried to create table:
create table bobDbTable(eid int)
which gives permission denied error;
so i granted permission:
GRANT CREATE TABLE TO bobDB_USER
then i again connected using bobLogin, & tried to create a table but it gave error:
The specified schema name "dbo" either does not exist or you do not have permission to use it.
why so? its creating the table in the dbo schema, thats why? so how do i grant him this permission ?
i dont want to create a new schema. is it necessary?
You would need to GRANT ALTER ON SCHEMA::dbo TO bobDB_USER to allow objects to be created in the dbo schema.
I would also use a Role too.
create role bobDB_ROLE
EXEC sp_addrolemember 'bobDB_ROLE', 'bobDB_USER'
GRANT ALTER ON SCHEMA::dbo TO bobDB_ROLE
However, you could addbobDB_USER into db_owner if it requires these rights
EXEC sp_addrolemember 'db_owner', 'bobDB_USER'
Note: end user permissions are quite different to admin type rights. If 'bobDB_USER' is an end user, then they should not be creating objects

ASP.NET Membership + User Creation configuration

I'm writing a small website in ASP.NET C#.
I've already made a database which will receive the user data and various other things.
Now I want to register users. I've found the MembershipUser and MembershipCreateStatus class and enum to be often used for this.
However, even though my database is seen in the Server Explorer of Visual Studio, I can't seem to link the User-creation to that database.
What I want is when I do this:
MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text);
It ends up in the database and table of my choice. I can't find how to configure this.
The ASP.Net membership provider uses its own tables/stored procedures for storing user data.
http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx
You can use your own table for profile info (that is, non-authentication information) using either the ProfileProvider or by using the guid assigned by in the aspnet_Users table as a key for your own table and retrieving the profile record after authentication occurs.
From the Visual Studio command prompt run the following:
aspnet_regsql -S [my server, eg: (local)\SQLEXPRESS] -E -A all -d [my database]
This will attach the ASP.NET user required stored procedures and tables to your database so that the built in Membership and Role Providers can actualy work.
use the WAT tool in VS to create your initial users if you need so you can test right away.

Categories