SQLSERVER(2000)修改密码时提示 “错误 2812: 未能找到存储过程 'sp_password'。” 解决方法

昨天给一个青岛的客户做管家婆的演示,开启了远程1433端口,早上在登陆管家婆就发现无法登陆,提示sa密码错误;我也没操作啥,为啥错误呢?看了一下系统日志,霍霍好多登陆信息,我一个虚拟机在内网做了演示,你能干啥哦;还这么疯狂的扫描;

现在有很多自动扫描1433端口的软件,会破坏sp_password存储过程。造成在修改SA密码的时候出现2812错误,那如何解决呢,我们现在来说说;

用WINDOWS身份验证登陆到SQL SERVER的查询工具。复制--粘贴--执行下面的代码即可;全程图解,具体请看下图;


-- SQL代码开始

sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE

go

use master
go

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_password]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_password]
go

create procedure sp_password
@old sysname = NULL, -- the old (current) password
@new sysname, -- the new password
@loginame sysname = NULL -- user to change password on
as
-- SETUP RUNTIME OPTIONS / DECLARE VARIABLES --
set nocount on
declare @self int
select @self = CASE WHEN @loginame is null THEN 1 ELSE 2 END

-- RESOLVE LOGIN NAME
if @loginame is null
select @loginame = suser_sname()

-- CHECK PERMISSIONS (SecurityAdmin per Richard Waymire) --
IF (not is_srvrolemember('securityadmin') = 1)
AND not @self = 1
begin
dbcc auditevent (107, @self, 0, @loginame, NULL, NULL, NULL)
raiserror(15210,-1,-1)
return (1)
end
ELSE
begin
dbcc auditevent (107, @self, 1, @loginame, NULL, NULL, NULL)
end

-- DISALLOW USER TRANSACTION --
set implicit_transactions off
IF (@@trancount > 0)
begin
raiserror(15002,-1,-1,'sp_password')
return (1)
end

-- RESOLVE LOGIN NAME (disallows nt names)
if not exists (select * from master.dbo.syslogins where
loginname = @loginame and isntname = 0)
begin
raiserror(15007,-1,-1,@loginame)
return (1)
end

-- IF non-SYSADMIN ATTEMPTING CHANGE TO SYSADMIN, REQUIRE PASSWORD (218078) --
if (@self <> 1 AND is_srvrolemember('sysadmin') = 0 AND exists
(SELECT * FROM master.dbo.syslogins WHERE loginname = @loginame and isntname = 0
AND sysadmin = 1) )
SELECT @self = 1

-- CHECK OLD PASSWORD IF NEEDED --
if (@self = 1 or @old is not null)
if not exists (select * from master.dbo.sysxlogins
where srvid IS NULL and
name = @loginame and
( (@old is null and password is null) or
(pwdcompare(@old, password, (CASE WHEN xstatus&2048 = 2048 THEN 1 ELSE 0 END)) = 1) ) )
begin
raiserror(15211,-1,-1)
return (1)
end

-- CHANGE THE PASSWORD --
update master.dbo.sysxlogins
set password = convert(varbinary(256), pwdencrypt(@new)), xdate2 = getdate(), xstatus = xstatus & (~2048)
where name = @loginame and srvid IS NULL

-- UPDATE PROTECTION TIMESTAMP FOR MASTER DB, TO INDICATE SYSLOGINS CHANGE --
exec('use master grant all to null')

-- FINALIZATION: RETURN SUCCESS/FAILURE --
if @@error <> 0
return (1)
raiserror(15478,-1,-1)
return (0) -- sp_password

GO
sp_configure 'allow updates', 0
RECONFIGURE WITH OVERRIDE

-- SQL代码结束

所写所说,是心之所感,思之所悟,行之所得;文当无敷衍,落笔求简洁。 以所舍,求所获;有所依,方所成!

更多请关注:老梁`s Blog

免责声明,若由于商用引起版权纠纷,一切责任均由使用者承担。 您必须遵守我们的协议,如果您下载了该资源行为将被视为对《免责声明》全部内容的认可->联系老梁投诉资源
Laoliang.Net资源全部来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。 敬请谅解! 侵权删帖/违法举报/投稿等事物联系邮箱:service@laoliang.net
老梁`s Blog(老梁博客) » SQLSERVER(2000)修改密码时提示 “错误 2812: 未能找到存储过程 'sp_password'。” 解决方法

发表评论

本站承接,网站推广(SEM,SEO),软件的安装的安装与调试,服务器的推荐以及配置,APP的开发与维护,网络或者web维护;财务软件,客户管理系统,人力资源,超市POS,医药管理,服务器安全,ecshop,金蝶,用友,管家婆;

立即查看 了解详情