When I run to alter the procedure, I get an error:
Msg 18487, Level 14, State 1, Line 1
Login failed for user 'tester'. Reason: The password of the account has expired.
However when I check under Security -> Logins, I can't find a user with this name.
I also tried removing the expiration with the following command:
ALTER LOGIN tester
WITH DEFAULT_DATABASE = [master],
DEFAULT_LANGUAGE = [us_english],
CHECK_EXPIRATION = OFF
The system says that the user does not exist or I don't have permission (I'm sysadmin)
Msg 15151, Level 16, State 1, Line 1
Cannot alter the login 'tester', because it does not exist or you do not have permission.
Per my comment...
Please verify that the stored procedure is not utilising a linked server which may contain/use the credentials indicated.
Stored procedures validate connections/credentials on recompile.
Related
The engineers uses this Access based app that takes data from SQL Server 2005.
The users download a file containing details of parts etc make amendments and upload it again. When the file is upload(checked-in) the information such as the modified date, userId etc is stored in SQL Server. When the user tries to check in they face this error:
The users that are working from home and use remote desktop connection to login into their account are the only one facing this error. The users that are on the office network do not get this error.
I tried making a proxy account and granting access to the user but that doesn't work.
It below query, I get the following errors:
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'GRANT'.
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'SIDNEY\UsersWindowsLoginId'.
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near 'UsersWindowsLoginId'`
Query:
CREATE LOGIN UsersWindowsLoginId
GRANT EXECUTE ON xp_cmdshell TO 'SIDNEY\UsersWindowsLoginId';
EXEC sp_xp_cmdshell_proxy_account 'UsersWindowsLoginId'
USE master;
GRANT CONTROL SERVER TO 'UsersWindowsLoginId'
GO
Also, this seems to be a recent phenomenon as the users have been working from home for a while now.
Any help is appreciated. Thanks!
First enable advanced option for run xp_cmdshell, for this need to change 1, below query to enable.Try this
USE [DatabaseName]
GO
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
Thanks and Regards
Aravind
I'm logged in with the user that is marked in the Azure portal as being the server admin.
I need to grant control database to a given user so that the sys.fn_get_audit_file can be executed.
But even with the admin user I'm getting the error
Msg 262, Level 14, State 1, Line 1
CONTROL permission denied in database 'master'.
Msg 297, Level 16, State 1, Line 1
The user does not have permission to perform this action.
Any suggestions
First make sure you are using correct authentication. E.g. Windows, Azure etc.
Also be sure you have permission to create database
Run below query on you database
ALTER SERVER ROLE sysadmin ADD MEMBER your-user;
GO
Refer this link for more information.
I have to write script in which I have create login and user, and give Execute on access to this USER to execute only single store procedure SP_SELECTDEPT but not directly only through role. So this way user will be having access to execute only this store procedure but it is not working.
so far I have done.
BEGIN TRANSACTION
USE master
CREATE LOGIN QGtestlogin WITH PASSWORD = 'test123', CHECK_POLICY=off
GO
USE DEPT
CREATE USER QGtestlogin FOR LOGIN QGtestlogin
go
CREATE ROLE QGtestrole AUTHORIZATION QGtestlogin
GO
GRANT EXECUTE ON SP_SELECTDEPT TO QGtestrole
go
if ##ERROR > 0
begin
rollback transaction
end
else begin
commit transaction
end
But when I login with this newly created user it is not even showing the store procedure to execute.
NOTE:
I have added the user to role member using sp_addrolemember
exec sp_addrolemember 'QGtestrole','QGtestlogin'
but still getting error:
Msg 229, Level 14, State 5, Procedure SP_SELECTDEPT, Line 14
The SELECT permission was denied on the object 'Dept', database 'DEPT', schema 'dbo'.
It seems to be problem with SQLEXPRESS edition, When I run the same code on my actual development database they get executed and QGtestlogin able to execute the Store Procedure.
I need to permission a user to a database right after a database restore.
I tried this:
Use [master]
go
restore database DBTest
from disk='E:\userTemp\DBTest1.bak'
WITH MOVE 'DBTest' TO 'E:\SQLData\DBTest1.mdf',
MOVE 'DBTest_log' TO 'F:\SQLData\DBTest1.ldf',
replace, recovery, stats=5, maxtransfersize=1048576
Print '---------------------------RESTORE COMPLETED ---------------------------'
-- Create the user.
CREATE USER [user_indi] FOR LOGIN [user_indi]
GO
USE [DBTest]
GO
EXEC sp_addrolemember N'db_owner', N'user_indi'
GO
When I do this, I get the following error:
Msg 15023, Level 16, State 1, Line 22
User, group, or role 'user_indi' already exists in the current database.
Msg 15410, Level 11, State 1, Procedure sp_addrolemember, Line 75
User or role 'user_indi' does not exist in this database.
So, what added the command to remove the user in the middle. Now it looks like this.
Use [master]
go
restore database DBTest
from disk='E:\userTemp\DBTest1.bak'
WITH MOVE 'DBTest' TO 'E:\SQLData\DBTest1.mdf',
MOVE 'DBTest_log' TO 'F:\SQLData\DBTest1.ldf',
replace, recovery, stats=5, maxtransfersize=1048576
Print '---------------------------RESTORE COMPLETED ---------------------------'
-- Remove the user
USE [DBTest]
GO
DROP USER [user_indi]
GO
-- Create the user.
CREATE USER [user_indi] FOR LOGIN [user_indi]
GO
USE [DBTest]
GO
EXEC sp_addrolemember N'db_owner', N'user_indi'
GO
Now, I get the error:
Msg 15151, Level 16, State 1, Line 2
Cannot drop the user 'user_indi', because it does not exist or you do not have permission.
I can't allow errors as I need to schedule this restore and permission job. Why am I getting this error and how can I workaround it?
RM
Your USE [DBTest] statements are in two different places.
In the first one, you're attempting to create the user in MASTER. In the second one, you're creating it in DBTest.
I have the following script:
ALTER ROLE [db_datareader] ADD MEMBER [DomainGroup123]
when I run this against SQL Server 2008 R2 I get this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'ADD'.
I have looked online, and found examples that use this exact statement (but with a different user.)
I have double checked that the login exists and is a valid user on the database I am using. Also I have SA permissions on the server.
What am I mssing?
Use sp_addrolemember.
EXECUTE sp_addrolemember db_datareader, 'UserName'
Found this answer: https://stackoverflow.com/a/456365/16241
That showed me that I can run it like this:
exec sp_addrolemember db_datareader, [DomainGroup123]
I did that and it worked.
I've noticed that depending on the version of the server, I need to go one of the following.
alter role RoleName add member UserName
or
execute sp_addrolemember RoleName, UserName
I'm thinking of changing my approach from trial-and-error to some kind of conditional but (a) this operation is performed quite seldom in my case and (b) I'm a bit lazy nowadays.