Share via


User Object

この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。

The User object exposes the attributes of a single Microsoft SQL Server database user.

現在のオブジェクトを表す SQL-DMO オブジェクト モデル

Properties

HasDBAccess Property

Name Property

ID Property

Role Property

Login Property

SystemObject Property

Methods

IsMember Method

ListObjectPermissions Method

ListDatabasePermissions Method

Remove Method (Objects)

ListMembers Method (Login, User)

Script Method

ListOwnedObjects Method

解説

A database user is a security principal enabling object access permission control at the finest level of granularity. A user represents a single SQL Server login within the scope of the database in which the user is defined.

With the User object, you can:

  • Create a database user.
  • Enumerate objects owned by a user and permissions on database objects.
  • Remove a database user.

The Name property of a User object is a character string. Name must be a valid string for the SQL Server sysname data type and cannot include a backslash character (\).

When creating a database user by using the User object, setting the Name property is optional. If the Name property is not set, a user is created having the same name as the value specified by using the Login property.

To create a database user

  1. Create a User object.

  2. Set the Login property indicating an existing SQL Server login.

  3. Set optional properties.

  4. Add the User object to the Users collection of a connected SQLServer Database object.

A database user cannot be removed if the user owns objects in the database. With SQL Distributed Management Objects (SQL-DMO), use the Owner property to reassign database object ownership.

To remove a database user

  1. Get the appropriate User object from the Users collection of a connected SQLServer Database object.

  2. Use the ListOwnedObjects method of the User object to enumerate database objects owned by the user.

  3. Use the Owner property to reassign ownership for all owned objects.

  4. Use the Remove method of the User object to remove the database user.

ms142648.note(ja-jp,SQL.90).gifメモ :
The User object is compatible with instances of SQL Server versions 7.0 and later. However, the User2 object extends the functionality of the User object for use with features that were introduced in SQL Server 2000.

参照

関連項目

User2 Object

ヘルプおよび情報

SQL Server 2005 の参考資料の入手