sp_ActiveDirectory_Obj

Transact-SQL Reference

Transact-SQL Reference

sp_ActiveDirectory_Obj

Controls the registration of a Microsoft® SQL Server™ database in the Microsoft Windows® 2000 Active Directory™.

Syntax

sp_ActiveDirectory_Obj [ @Action = ] N'action'

    [, [ @ObjType = ] N'database' ]

    , [ @ObjName = ] N'database_name'

Arguments

[ @Action = ] N'action'

Specifies whether the Active Directory object registering the SQL Server database is to be created, updated, or deleted. action is nvarchar(20) with a default of N'create'.

Value Description
create Registers the SQL Server database in the Active Directory by creating an MS-SQL-SQLDatabase object in the directory. The MS-SQL-SQLDatabase object records the attributes of the database at the time the create action is performed. If you specify create and the database is already registered, an update action is performed.
update Refreshes the attributes registered for the database in the Active Directory by updating the attributes recorded in the MS-SQL-SQLDatabase object in the Active Directory. If you specify update and the database is not registered, a create action is performed.
delete Removes the Active Directory registration for the database by deleting the MS-SQL_SQLDatabase object from the Active Directory.

[ @ObjType = ] N'database' ]

Specifies that sp_ActiveDirectory_Obj perform the requested action on a database object in the Active Directory. N'database' is nvarchar(15), with a default of N'database'. In SQL Server 2000, N'database' is the only supported value.

[ @ObjName = ] N'database_name'

Specifies the name of the database for which the registration action is performed. database_name is sysname, and you must specify a value. database_name must specify the name of a database that exists in the instance of SQL Server in which sp_ActiveDirectory_Obj is executed. database_name must conform to the rules for identifiers.

Return Code Values

0 (success) or 1 (failure)

Result Sets

None

Remarks

The current instance of SQL Server must be registered in the Active Directory before you can register any of the databases in the instance. If you remove the registration of the instance from the Active Directory, all of the registrations for databases in that instance are also removed.

In SQL Server 2000, databases are the only entities you can register in the Active Directory using sp_ActiveDirectory_Obj directly. To control the registration of instances of SQL Server in the Active Directory, use sp_ActiveDirectory_SCP. To control the registration of replication publications in the Active Directory, use the replication stored procedures: sp_addpublication, sp_changepublication, sp_addmergepublication, and sp_changemergepublication.

Permissions

Only members of the sysadmin fixed server role and the db_owner fixed database role can execute sp_ActiveDirectory_SCP.

Examples

This example registers the Northwind database from the current instance of SQL Server in the Active Directory.

DECLARE @RetCode INT

EXEC @RetCode = sp_ActiveDirectory_Obj @Action = N'create',
     @ObjType = N'database',
     @ObjName = 'Northwind'

PRINT 'Return code = ' + CAST(@RetCode AS VARCHAR)

See Also

Active Directory Integration

Active Directory Services

sp_ActiveDirectory_SCP

sp_addmergepublication

sp_addpublication

sp_changemergepublication

sp_changepublication