sp_ActiveDirectory_Obj (Transact-SQL)
Controls the registration of a Microsoft SQL Server database in the Microsoft Windows Active Directory.
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.
Databases are the only entities you can register in the Active Directory by using sp_ActiveDirectory_Obj directly. To control the registration of instances of SQL Server in the Active Directory, use sp_ActiveDirectory_SCP.
Note |
|---|
Active Directory registration can only be modified by the account that created it. When you change the security account used by the SQL Server service, delete the Active Directory registration, change the service account, and then create the Active Directory registration again. |
The following example registers in the Active Directory, the AdventureWorks2008R2 database from the current instance of SQL Server.
DECLARE @RetCode INT
EXEC @RetCode = sp_ActiveDirectory_Obj @Action = N'create',
@ObjType = N'database',
@ObjName = N'AdventureWorks2008R2';
PRINT 'Return code = ' + CAST(@RetCode AS VARCHAR);