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.
sitijaafarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 & Architect, EE Solution GuideCommented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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 & Architect, EE Solution GuideCommented:
>> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 & Architect, EE Solution GuideCommented:
Glad to see you fixed it..
0
sitijaafarAuthor Commented:
Thanks rrjegan17.
0
Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
Welcome..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.