[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 832
  • Last Modified:

Cannot find the user 'admin', because it does not exist or you do not have permission.

Hi all,
I want to grant SELECT permission for admin user using the below command:

grant SELECT on dbo.audit_trail to [admin];

But the problem is I got this error message:
Cannot find the user 'admin', because it does not exist or you do not have permission.
0
sitijaafar
Asked:
sitijaafar
  • 5
  • 4
1 Solution
 
RiteshShahCommented:
have you created "Admin" login/user yourself? as in SQL Server, master login is "SA" not login ships with SQL Server such as "Admin".

are you talking about windows authentication?
0
 
sitijaafarAuthor Commented:
Yes, I already create the admin user,  I'm using sql server authentication.
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Seems like you have created Admin login alone and not user admin for your database.
Run this statement in your database and then check:

-- Run this statement if login doesn't exists
CREATE LOGIN admin WITH PASSWORD = 'pass@123';
USE ur_db_name;
CREATE USER admin ;
GO
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sitijaafarAuthor Commented:
I run the above statement and I got the below message:

Msg 15025, Level 16, State 1, Line 2
The server principal 'admin' already exists.
Msg 15063, Level 16, State 1, Line 4
The login already has an account under a different user name.
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
>> The login already has an account under a different user name.

Then you have your Login and User name present in the server and databases respectively.
Ok.. Login now with sa or user with some high privileges into the server and try to do this..
* Expand SSMS --> Security --> Logins --> Right click admin login
* Go to database mapping and uncheck for this particular database
* Click Ok
* Now go to database mapping again and then choose this database again and then grant necessary db roles if any
* Try granting the SELECT permission again which should work.
0
 
sitijaafarAuthor Commented:
When I go to database mapping and uncheck for the database and click ok.  It prompt below message:

Is it my ms sql have a problem?
error.JPG
0
 
sitijaafarAuthor Commented:
I already can solve the  error using the
 sp_changedbowner sa

and able to uncheck for the database for admin.  I also Try granting the SELECT permission again and it's work. Thanks.

0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Glad to see you fixed it..
0
 
sitijaafarAuthor Commented:
Thanks rrjegan17.
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Welcome..
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now