Export (0) Print
Expand All

User Class

The User object represents a SQL Server user.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

'Declaration
<PhysicalFacetAttribute> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class User _
	Inherits ScriptNameObjectBase _
	Implements ISfcSupportsDesignMode, IObjectPermission, ICreatable, IDroppable,  _
	IAlterable, IRenamable, IExtendedProperties, IScriptable, IUserOptions,  _
	IDmfFacet
'Usage
Dim instance As User

The User type exposes the following members.

  NameDescription
Public methodUserInitializes a new instance of the User class.
Public methodUser(Database, String)Initializes a new instance of the User class on the specified database with the specified name.
Top

  NameDescription
Public propertyAsymmetricKeyGets or sets the asymmetric key for the user.
Public propertyAuthenticationTypeGets a string value that describes the mechanism used to authenticate the user.
Public propertyCertificateGets or sets the certificate for the user.
Public propertyCreateDateGets the date and time when the database user was created.
Public propertyDateLastModifiedGets the date and time when the database user was last modified.
Public propertyDefaultLanguageGets or sets the default language for the user.
Public propertyDefaultSchemaGets the default schema for the database user.
Public propertyEventsGets the events that are associated with the database user.
Public propertyExtendedPropertiesGets the extended properties of the database user.
Public propertyHasDBAccessGets the Boolean property that specifies whether the database user has access to the database.
Public propertyIDGets the ID value that uniquely identifies the database user.
Public propertyIsSystemObjectGets the Boolean property that specifies whether the database user is a system object.
Public propertyLoginGets the login that is associated with the database user.
Public propertyLoginTypeGets the type of login that is associated with the database user, such as whether it is a Windows group or a SQL Server standard login.
Public propertyNameGets or sets a String value that specifies the name of the user. (Overrides NamedSmoObject.Name.)
Public propertyParentGets the Database object that is the parent of the User object.
Public propertyPropertiesGets a collection of Property objects that represent the object properties. (Inherited from SqlSmoObject.)
Public propertySidGets the security identification number (SID) value of the database user.
Public propertyStateGets the state of the referenced object. (Inherited from SmoObjectBase.)
Public propertyUrnGets the Uniform Resource Name (URN) address value that uniquely identifies the object. (Inherited from SqlSmoObject.)
Public propertyUserDataGets or sets user-defined data associated with the referenced object. (Inherited from SmoObjectBase.)
Public propertyUserTypeGets or sets the type of user.
Top

  NameDescription
Public methodAddToRoleAdds the database user to the specified role.
Public methodAlterUpdates any User object property changes on the instance of Microsoft SQL Server. 
Public methodChangePassword(SecureString)Changes the user password.
Public methodChangePassword(String)Changes the user password.
Public methodChangePassword(SecureString, SecureString)Changes the user password.
Public methodChangePassword(String, String)Changes the user password.
Public methodCreateCreates a database user on the instance of SQL Server as defined by the User object.
Public methodCreate(SecureString)Creates a database user on the instance of SQL Server as defined by the User object with specified password using a secure string.
Public methodCreate(String)Creates a database user on the instance of SQL Server as defined by the User object with specified password.
Public methodDeny(ObjectPermissionSet, String)Denies access to the specified permission for the specified grantee on the database user.
Public methodDeny(ObjectPermissionSet, String())Denies access to the specified permission for the specified grantees on the database user.
Public methodDeny(ObjectPermissionSet, String, Boolean)Denies access to the specified permission for the specified grantee and other users whom the grantee granted access on the database user.
Public methodDeny(ObjectPermissionSet, String(), Boolean)Denies access to the specified permission for the specified grantees on the database user.
Public methodDiscoverDiscovers a list of type Object. (Inherited from SqlSmoObject.)
Public methodDropRemoves the user from the database.
Public methodEnumObjectPermissionsEnumerates a list of object permissions for the database user.
Public methodEnumObjectPermissions(String)Enumerates a list of object permissions for a specified grantee on the database user.
Public methodEnumObjectPermissions(ObjectPermissionSet)Enumerates a list of object permissions for a specified permission on the database user.
Public methodEnumObjectPermissions(String, ObjectPermissionSet)Enumerates a list of object permissions for a specified grantee and a specified permission on the database user.
Public methodEnumOwnedObjectsEnumerates a list of object that the database user owns.
Public methodEnumRolesEnumerates a list of roles of which the database user is a member.
Public methodEquals (Inherited from Object.)
Protected methodFormatSqlVariantFormats an object as SqlVariant type. (Inherited from SqlSmoObject.)
Protected methodGetContextDBGets the context database that is associated with this object. (Inherited from SqlSmoObject.)
Protected methodGetDBNameGets the database name that is associated with the object. (Inherited from SqlSmoObject.)
Public methodGetHashCode (Inherited from Object.)
Protected methodGetPropValueGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetPropValueOptionalGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetPropValueOptionalAllowNullGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetServerObjectGets the server of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Public methodGetType (Inherited from Object.)
Public methodGrant(ObjectPermissionSet, String)Grants access to the specified permission for the specified grantee on the database user.
Public methodGrant(ObjectPermissionSet, String())Grants access to the specified permission for the specified grantees on the database user.
Public methodGrant(ObjectPermissionSet, String, Boolean)Grants access to the specified permission and the ability to grant access to other users for the specified grantee on the database user.
Public methodGrant(ObjectPermissionSet, String(), Boolean)Grants access to the specified permission and the ability to grant access to other users for the specified grantees on the database user.
Public methodGrant(ObjectPermissionSet, String, Boolean, String)Grants access to the specified permission and the ability to grant access to other users for the specified grantee on the database user.
Public methodGrant(ObjectPermissionSet, String(), Boolean, String)Grants access to the specified permission and the ability to grant access to other users for the specified grantee on the database user under an assumed role.
Public methodInitializeInitializes the object and forces the properties be loaded. (Inherited from SqlSmoObject.)
Public methodInitialize(Boolean)Initializes the object and forces the properties be loaded. (Inherited from SqlSmoObject.)
Public methodIsMemberVerifies whether the database user is a member of the specified role.
Protected methodIsObjectInitializedVerifies whether the object has been initialized. (Inherited from SqlSmoObject.)
Protected methodIsObjectInSpaceVerifies whether the object is isolated or connected to the instance of SQL Server. (Inherited from SqlSmoObject.)
Public methodMakeContainedConverts a login mapped user to a contained user with password using the sys.sp_copy_password_to_user stored procedure.
Public methodRefreshRefreshes the script name. (Inherited from ScriptNameObjectBase.)
Public methodRenameRenames the database user.
Public methodRevoke(ObjectPermissionSet, String)Revokes previously granted permissions from a grantee on the database user.
Public methodRevoke(ObjectPermissionSet, String())Revokes previously granted permissions from a list of grantees on the database user.
Public methodRevoke(ObjectPermissionSet, String, Boolean, Boolean)Revokes previously granted permissions from a grantee on the database user and any other users to whom the grantee has granted access. The grantee is also given the ability to revoke other users' access.
Public methodRevoke(ObjectPermissionSet, String(), Boolean, Boolean)Revokes previously granted permissions from the grantees on the database user and any other users to whom the grantees have granted access. The grantees are also given the ability to revoke other users' access.
Public methodRevoke(ObjectPermissionSet, String, Boolean, Boolean, String)Revokes previously granted permissions from a grantee on the database user and any other users to whom the grantee has granted access. The grantee is also given the ability to revoke other users' access under an assumed role.
Public methodRevoke(ObjectPermissionSet, String(), Boolean, Boolean, String)Revokes previously granted permissions from grantees on the database user and any other users to whom the grantees have granted access. The grantees are also given the ability to revoke other users' access under an assumed role.
Public methodScriptGenerates a Transact-SQL script that can be used to re-create the database user.
Public methodScript(ScriptingOptions)Generates a Transact-SQL script that can be used to re-create the database user as specified by the script options.
Protected methodSetParentImplSets the parent of the SqlSmoObject to the newParent parameter. (Inherited from SqlSmoObject.)
Public methodToStringReturns a String that represents the referenced object. (Inherited from SqlSmoObject.)
Public methodValidateValidates the state of an object. (Inherited from SmoObjectBase.)
Top

  NameDescription
Public eventPropertyChangedRepresents the event that occurs when a property is changed. (Inherited from SqlSmoObject.)
Public eventPropertyMetadataChangedRepresents the event that occurs when property metadata changes. (Inherited from SqlSmoObject.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIAlienObject.DiscoverDiscovers any dependencies. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetDomainRootReturns the root of the domain. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetParentGets the parent of this object. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetPropertyTypeGets the type of the specified property. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetPropertyValueGets the value of the specified property. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetUrnGets the Unified Resource Name (URN) of the object. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.ResolveGets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.SetObjectStateSets the object state to the specified SfcObjectState value. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.SetPropertyValueSets the property value. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodISfcPropertyProvider.GetPropertySetGets the interface reference to the set of properties of this object. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate propertyISfcSupportsDesignMode.IsDesignModeGets a Boolean value that specifies whether the user supports design mode.
Top

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

To set User object properties, uses must have ALTER ANY USER permission on the database or be a member of the db_owner fixed database role.

To change the default schema, users must have ALTER permission on the specified user or be the owner of the user.

To create or drop a user, users must have ALTER ANY USER permission on the fixed server role or be a member of the db_owner fixed database role.

To grant, deny, or revoke permission on the specified user to other users, users must have CONTROL permission on the specified user.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft