Use ALTER LOGIN to change User's own Password

前端 未结 2 1588
轮回少年
轮回少年 2020-12-24 12:27

I have a stored procedure that runs the following:

\'ALTER LOGIN \' + @Login + \' WITH PASSWORD = \'\'\' + @Password + \'\'\'\'

I get the f

相关标签:
2条回答
  • 2020-12-24 12:53

    I think to perform an ordinary password change for a user, who doesn't have ALTER ANY LOGIN, you must supply the OLD_PASSWORD parameter also. This would match the example from the older sp_password stored procedure:

    The following example shows how to use ALTER LOGIN to change the password for the login Victoria from B3r1000d#2-36 to V1cteAmanti55imE. This is the preferred method. User Victoria can execute this command without additional permissions. Other users require ALTER ANY LOGIN permission:

    ALTER LOGIN Victoria WITH 
         PASSWORD = 'V1cteAmanti55imE' 
         OLD_PASSWORD = 'B3r1000d#2-36';
    GO
    
    0 讨论(0)
  • 2020-12-24 12:56

    You can have your application run as a user with sufficient rights. For that, you would create a service account for the application in SQL Server, and then have your application run as that user.

    However, it might be better to create a Users table for your application and manage this data there, rather than allowing your users direct access to altering logins.

    0 讨论(0)
提交回复
热议问题