修改登陆账户信息注意事项






使用T-SQL脚本修改登陆账户信息
启用或禁用此登录名
语法
--创建登录用户
alter login login_name { enable | disable }
go
语法解析
示例
--创建登录用户
alter login testuser
disable
go
示例结果

更改
--修改登录账户属性
alter login login_name
with
password={ 'password' | hashed_password hashed [old_password='oldpassword' [must_change | unlock] ]}[,]
default_database=database[,]
default_language=language[,]
name=login_name[,]
check_policy={ on | off }[,]
check_expiration={ on | off }[,]
credential=credential_name[,]
no credential[,]
add credential credential_name[,]
drop credential credential_name
语法解析
示例
--修改登陆账户属性
alter login testuser
with
password='1234',--default_database=database[,]
--default_language=language[,]
name=testuser,check_policy=on,check_expiration=on
--credential=credential_name [,]
--no credential[,]
--add credential credential_name[,]
--drop credential credential_name
--可以添加多个服务器角色
--创建服务器角色,服务器角色用于向用户授权服务器范围内的安全特权
--alter server role [bulkadmin] drop member [testuser];
--go
--alter server role [dbcreator] drop member [testuser];
--go
--alter server role [diskadmin] drop member [testuser];
--go
--alter server role [processadmin] drop member [testuser];
--go
--alter server role [securityadmin] drop member [testuser];
--go
--alter server role [serveradmin] drop member [testuser];
--go
--alter server role [setupadmin] drop member [testuser];
--go
--alter server role [sysadmin] drop member [testuser];
--go
--创建用户映射,映射到此登录名的用户
--use [master]
--go
--drop user [testuser]
--go
--use [msdb]
--go
--drop user [testuser]
--go
--use [ReportServer]
--go
--drop user [testuser]
--go
--use [ReportServerTempDB]
--go
--drop user [testuser]
--go
--use [tempdb]
--go
--drop user [testuser]
--go
--use [testss]
--go
--drop user [testuser]
--go
----声明数据库引用
--use [testss]
--go
----授予不安全的程序集
--grant unsafe assembly to testuser;
--go
----授予查看服务器状态
--grant view server state to testuser;
--go
----授予查看任意定义
--grant view any definttion to testuser;
--go
----授予查看任意数据库
--grant view any database to testuser;
--go
----授予创建DDL事件通知
--grant create ddl event notification to testuser;
--go
----授予创建端点
--grant create endpoint to testuser;
--go
----授予创建服务器角色
--grant create server role to testuser;
--go
----授予创建跟踪事件通知
--grant create trace event notification to testuser;
--go
----授予创建可用性组
--grant create availability group to testuser;
--go
----授予创建任意数据库
--grant create any database to testuser;
--go
----授予更改服务器状态
--grant alter server state to testuser;
--go
----授予更改跟踪
--grant alter trace to testuser;
--go
----授予更改任何服务器角色
--grant alter any server role to testuser;
--go
----授予更改任何可用性组
--grant alter any availability group to testuser;
--go
----授予更改任意登录名
--grant alter any login to testuser;
--go
----授予更改任意端点
--grant alter any endpoint to testuser;
--go
----授予更改任意服务器审核
--grant alter any server audit to testuser;
--go
----授予更改任意权限
--grant alter any connection to testuser;
--go
----授予更改任意连接服务器
--grant alter any linked server to testuser;
--go
----授予更改任意凭据
--grant alter any credential to testuser;
--go
----授予更改任意事件会话
--grant alter any event session to testuser;
--go
----授予更改任意事件通知
--grant alter any event notification to testuser;
--go
----授予更改任意数据库
--grant alter any database to testuser;
--go
----授予更改设置
--grant alter settings to testuser;
--go
----授予更改资源
--grant alter resources to testuser;
--go
----授予关闭
--grant shutdown to testuser;
--go
----授予管理大容量操作
--grant administer bulk operations to testuser;
--go
----授予控制服务器
--grant control server to testuser;
--go
----授予连接SQL
--grant connect sql to testuser;
--go
----授予外部访问程序集
--grant external access assembly to testuser;
--go
----授予验证服务器
--grant authenticate server to testuser;
--go
--设置是否允许连接到数据库引擎
--deny connect sql to testuser;
--go
--是否允许登录
--alter login testuser disable;
--go
----用户状态
----声明默认数据库引用
--use [testuser]
--go
----是否允许用户连接到数据库引擎
--deny connect sql to [testuser];
--go
----是否允许登录
--alter login [testuser] { enable | disable }
--go
示例结果

 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|