Поделиться через


Класс DatabaseRole

The DatabaseRole object represents a SQL Server database security role.

Иерархия наследования

System.Object
  Microsoft.SqlServer.Management.Smo.SmoObjectBase
    Microsoft.SqlServer.Management.Smo.SqlSmoObject
      Microsoft.SqlServer.Management.Smo.NamedSmoObject
        Microsoft.SqlServer.Management.Smo.ScriptNameObjectBase
          Microsoft.SqlServer.Management.Smo.DatabaseRole

Пространство имен:  Microsoft.SqlServer.Management.Smo
Сборка:  Microsoft.SqlServer.Smo (в Microsoft.SqlServer.Smo.dll)

Синтаксис

'Декларация
<StateChangeEventAttribute("CREATE_ROLE", "ROLE")> _
<StateChangeEventAttribute("ALTER_ROLE", "ROLE")> _
<PhysicalFacetAttribute> _
<SfcElementTypeAttribute("Role")> _
<StateChangeEventAttribute("ALTER_AUTHORIZATION_DATABASE", "ROLE")> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.None Or AutomatedPolicyEvaluationMode.Enforce Or AutomatedPolicyEvaluationMode.CheckOnChanges Or AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class DatabaseRole _
    Inherits ScriptNameObjectBase _
    Implements ISfcSupportsDesignMode, IObjectPermission, ICreatable, IDroppable,  _
    IAlterable, IRenamable, IExtendedProperties, IScriptable
'Применение
Dim instance As DatabaseRole
[StateChangeEventAttribute("CREATE_ROLE", "ROLE")]
[StateChangeEventAttribute("ALTER_ROLE", "ROLE")]
[PhysicalFacetAttribute]
[SfcElementTypeAttribute("Role")]
[StateChangeEventAttribute("ALTER_AUTHORIZATION_DATABASE", "ROLE")]
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode.None|AutomatedPolicyEvaluationMode.Enforce|AutomatedPolicyEvaluationMode.CheckOnChanges|AutomatedPolicyEvaluationMode.CheckOnSchedule)]
public sealed class DatabaseRole : ScriptNameObjectBase, 
    ISfcSupportsDesignMode, IObjectPermission, ICreatable, IDroppable, IAlterable, 
    IRenamable, IExtendedProperties, IScriptable
[StateChangeEventAttribute(L"CREATE_ROLE", L"ROLE")]
[StateChangeEventAttribute(L"ALTER_ROLE", L"ROLE")]
[PhysicalFacetAttribute]
[SfcElementTypeAttribute(L"Role")]
[StateChangeEventAttribute(L"ALTER_AUTHORIZATION_DATABASE", L"ROLE")]
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode::None|AutomatedPolicyEvaluationMode::Enforce|AutomatedPolicyEvaluationMode::CheckOnChanges|AutomatedPolicyEvaluationMode::CheckOnSchedule)]
public ref class DatabaseRole sealed : public ScriptNameObjectBase, 
    ISfcSupportsDesignMode, IObjectPermission, ICreatable, IDroppable, IAlterable, 
    IRenamable, IExtendedProperties, IScriptable
[<SealedAttribute>]
[<StateChangeEventAttribute("CREATE_ROLE", "ROLE")>]
[<StateChangeEventAttribute("ALTER_ROLE", "ROLE")>]
[<PhysicalFacetAttribute>]
[<SfcElementTypeAttribute("Role")>]
[<StateChangeEventAttribute("ALTER_AUTHORIZATION_DATABASE", "ROLE")>]
[<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.None|AutomatedPolicyEvaluationMode.Enforce|AutomatedPolicyEvaluationMode.CheckOnChanges|AutomatedPolicyEvaluationMode.CheckOnSchedule)>]
type DatabaseRole =  
    class 
        inherit ScriptNameObjectBase 
        interface ISfcSupportsDesignMode 
        interface IObjectPermission 
        interface ICreatable 
        interface IDroppable 
        interface IAlterable 
        interface IRenamable 
        interface IExtendedProperties 
        interface IScriptable 
    end
public final class DatabaseRole extends ScriptNameObjectBase implements ISfcSupportsDesignMode, IObjectPermission, ICreatable, IDroppable, IAlterable, IRenamable, IExtendedProperties, IScriptable

Тип DatabaseRole обеспечивает доступ к следующим элементам.

Конструкторы

  Имя Описание
Открытый метод DatabaseRole() Initializes a new instance of the DatabaseRole class.
Открытый метод DatabaseRole(Database, String) Initializes a new instance of the DatabaseRole class.

В начало

Свойства

  Имя Описание
Открытое свойство CreateDate Gets the date and time when the database role was created.
Открытое свойство DateLastModified Gets the date and time when the database role was last modified.
Открытое свойство ExtendedProperties Gets the extended properties of the database role.
Открытое свойство ID Gets the ID value that uniquely identifies the database role.
Открытое свойство IsFixedRole Gets the Boolean property value that specifies whether the database role is a fixed role or a user-defined role.
Открытое свойство Name Gets or sets a String value that specifies the name of the database role. (Переопределяет NamedSmoObject.Name.)
Открытое свойство Owner Gets or sets the owner of the database role.
Открытое свойство Parent Gets or sets the Database object that is the parent of the DatabaseRole object.
Открытое свойство Properties Gets a collection of Property objects that represent the object properties. (Производный от SqlSmoObject.)
Открытое свойство State Gets the state of the referenced object. (Производный от SmoObjectBase.)
Открытое свойство Urn Gets the Uniform Resource Name (URN) address value that uniquely identifies the object. (Производный от SqlSmoObject.)
Открытое свойство UserData Gets or sets user-defined data associated with the referenced object. (Производный от SmoObjectBase.)

В начало

Методы

  Имя Описание
Открытый метод AddMember Adds an existing database user or database role to the database role.
Открытый метод Alter Updates any DatabaseRole object property changes on the instance of Microsoft SQL Server.
Открытый метод Create Creates a database role on the instance of Microsoft SQL Server as defined by the DatabaseRole object.
Открытый метод Deny(ObjectPermissionSet, String) Denies the specified set of permissions for the specified grantee on the database role.
Открытый метод Deny(ObjectPermissionSet, array<String[]) Denies the specified set of permissions for the specified grantees on the database role.
Открытый метод Deny(ObjectPermissionSet, String, Boolean) Denies the specified set of permissions for the specified grantee and other users that the grantee granted the specified set of permissions on the database role.
Открытый метод Deny(ObjectPermissionSet, array<String[], Boolean) Denies the specified set of permissions for the specified grantees and other users that the grantee granted the specified set of permissions on the database role.
Открытый метод Discover Discovers a list of type Object. (Производный от SqlSmoObject.)
Открытый метод Drop Drops the database role.
Открытый метод DropMember Removes the specified database user or role from the referenced database role.
Открытый метод EnumAgentProxyAccounts Returns a list of agent proxy accounts that are assigned to the database role.
Открытый метод EnumMembers Returns a list of database users that are members of the database role.
Открытый метод EnumObjectPermissions() Returns a list of object permissions assigned to the referenced database role.
Открытый метод EnumObjectPermissions(String) Returns a list of object permissions assigned to the referenced database role for the specified member of the role.
Открытый метод EnumObjectPermissions(ObjectPermissionSet) Returns a list of object permissions assigned to the referenced database role for the specified set of object permissions.
Открытый метод EnumObjectPermissions(String, ObjectPermissionSet) Returns a list of object permissions assigned to the referenced database role for the specified member of the role and for the specified set of permissions.
Открытый метод EnumRoles Returns a list of the roles that the referenced database role is a member of.
Открытый метод Equals (Производный от Object.)
Защищенный метод FormatSqlVariant Formats an object as SqlVariant type. (Производный от SqlSmoObject.)
Защищенный метод GetContextDB Gets the context database that is associated with this object. (Производный от SqlSmoObject.)
Защищенный метод GetDBName Gets the database name that is associated with the object. (Производный от SqlSmoObject.)
Открытый метод GetHashCode (Производный от Object.)
Защищенный метод GetPropValue Gets a property value of the SqlSmoObject object. (Производный от SqlSmoObject.)
Защищенный метод GetPropValueOptional Gets a property value of the SqlSmoObject object. (Производный от SqlSmoObject.)
Защищенный метод GetPropValueOptionalAllowNull Gets a property value of the SqlSmoObject object. (Производный от SqlSmoObject.)
Защищенный метод GetServerObject Gets the server of the SqlSmoObject object. (Производный от SqlSmoObject.)
Открытый метод GetType (Производный от Object.)
Открытый метод Grant(ObjectPermissionSet, String) Grants the specified set of permissions to the specified grantee on the database role.
Открытый метод Grant(ObjectPermissionSet, array<String[]) Grants the specified set of permissions to the specified grantees on the database role.
Открытый метод Grant(ObjectPermissionSet, String, Boolean) Grants access to the specified permission to the grantee and the ability to grant access to other users on the database role.
Открытый метод Grant(ObjectPermissionSet, array<String[], Boolean) Grants access to the specified permission to the grantees and the ability to grant access to other users on the database role.
Открытый метод Grant(ObjectPermissionSet, String, Boolean, String) Grants the specified set of permissions to the grantees and the ability to grant the set of permissions to other users on the database role under an assumed role.
Открытый метод Grant(ObjectPermissionSet, array<String[], Boolean, String) Grants the specified set of permissions to the grantees and the ability to grant the set of permissions to other users on the database role under an assumed role.
Открытый метод Initialize() Initializes the object and forces the properties be loaded. (Производный от SqlSmoObject.)
Открытый метод Initialize(Boolean) Initializes the object and forces the properties be loaded. (Производный от SqlSmoObject.)
Защищенный метод IsObjectInitialized Verifies whether the object has been initialized. (Производный от SqlSmoObject.)
Защищенный метод IsObjectInSpace Verifies whether the object is isolated or connected to the instance of SQL Server. (Производный от SqlSmoObject.)
Открытый метод Refresh Refreshes the script name. (Производный от ScriptNameObjectBase.)
Открытый метод Rename Renames the database role.
Открытый метод Revoke(ObjectPermissionSet, String) Revokes a previously granted set of permissions from a grantee on the database role.
Открытый метод Revoke(ObjectPermissionSet, array<String[]) Revokes a previously granted set of permissions from a list of grantees on the database role.
Открытый метод Revoke(ObjectPermissionSet, String, Boolean, Boolean) Revokes previously granted permissions from a grantee on the database role and any other users to whom the grantee has granted the specified set of permissions. The grantee is also given the ability to revoke the specified set of permissions from other users under an assumed role.
Открытый метод Revoke(ObjectPermissionSet, array<String[], Boolean, Boolean) Revokes previously granted permissions from grantees on the database role and any other users to whom the grantees have granted the specified set of permissions. The grantees are also given the ability to revoke the specified set of permissions from other users under an assumed role.
Открытый метод Revoke(ObjectPermissionSet, String, Boolean, Boolean, String) Revokes previously granted permissions from a grantee on the database role and any other users to whom the grantee has granted the specified set of permissions. The grantee is also given the ability to revoke the specified set of permissions from other users under an assumed role.
Открытый метод Revoke(ObjectPermissionSet, array<String[], Boolean, Boolean, String) Revokes previously granted permissions from grantees on the database role and any other users to whom the grantees have granted the specified set of permissions. The grantees are also given the ability to revoke the specified set of permissions from other users under an assumed role.
Открытый метод Script() Generates a Transact-SQL script that can be used to re-create the Microsoft SQL Server database role.
Открытый метод Script(ScriptingOptions) Generates a Transact-SQL script that can be used to re-create the Microsoft SQL Server database role as specified by the scripting options.
Защищенный метод SetParentImpl Sets the parent of the SqlSmoObject to the newParent parameter. (Производный от SqlSmoObject.)
Открытый метод ToString Returns a String that represents the referenced object. (Производный от SqlSmoObject.)
Открытый метод Validate Validates the state of an object. (Производный от SmoObjectBase.)

В начало

События

  Имя Описание
Открытое событие PropertyChanged Represents the event that occurs when a property is changed. (Производный от SqlSmoObject.)
Открытое событие PropertyMetadataChanged Represents the event that occurs when property metadata changes. (Производный от SqlSmoObject.)

В начало

Явные реализации интерфейса

  Имя Описание
Явная реализация интерфейсаЗакрытый метод IAlienObject.Discover Discovers any dependencies. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetDomainRoot Returns the root of the domain. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetParent Gets the parent of this object. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetPropertyType Gets the type of the specified property. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetPropertyValue Gets the value of the specified property. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.GetUrn Gets the Unified Resource Name (URN) of the object. Не ссылайтесь на этот элемент непосредственно из кода. Он поддерживает работу инфраструктуры SQL Server. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.Resolve Gets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.SetObjectState Sets the object state to the specified SfcObjectState value. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод IAlienObject.SetPropertyValue Sets the property value. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытый метод ISfcPropertyProvider.GetPropertySet Gets the interface reference to the set of properties of this object. (Производный от SqlSmoObject.)
Явная реализация интерфейсаЗакрытое свойство ISfcSupportsDesignMode.IsDesignMode Gets a Boolean value that specifies whether the database role supports design mode.

В начало

Замечания

To get DatabaseRole object properties, users can be a member of the public fixed server role.

To set DatabaseRole object properties, users must have ALTER permission on the database role.

To create a database role, users must have CREATE ROLE permission on the parent database.

To drop a database role, users must have ALTER ANY ROLE permission on the parent database.

To add or remove members from the database role, users must be members of the db_owner or db_security admin fixed database role.

To grant, deny, or revoke permission on the database for other users, users must have CONTROL permission on the database role.

Thread Safety

Все общие статические члены этого типа (Shared в Microsoft Visual Basic) можно использовать в многопоточных операциях. Потокобезопасная работа с членами экземпляров типа не гарантируется.

Примеры

Управление пользователями, ролями и именами входа

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.

См. также

Справочник

Пространство имен Microsoft.SqlServer.Management.Smo

Другие ресурсы

Управление пользователями, ролями и именами входа

Роли уровня базы данных

CREATE ROLE (Transact-SQL)