Stopping a Service in Active Directory

Dim ServiceObj As IADsServiceOperations
Dim AdsObj As IADs

'Path “NTDSloc://Domain1/ComputerA/Service1" identifies service “Service1”

'"NTDSloc:" is the namespace for local resources

'Descriptor "server=DMSserver01" specifies that DMS server is on computer "DMSserver01"

Set ServiceObj = GetObject("NTDSloc://Domain1/ComputerA/Service1/server=DMSserver01")
Set AdsObj = ServiceObj

' IADs interface provides the following four properties

'Note: You will have to put these properties for LRDS in WIN2K

AdsObj.Put "DA_DRole_Server_Name", "DCdomain1"
'specify name of the DC for WIN2K domain “Domain1”

AdsObj.Put "DA_User_Name", "Domain1\Charlie"

'Name of the User connected to the AD tree

AdsObj.Put "DA_Password", "pwd"

'Password of the User

AdsObj.Put "DA_Use_Role_Type", 2

'Specifies the AD roles

‘ Next line will give error ERROR: ”Access Denied” as Charlie do not have permissions to stop a service.


'Release the Object

Set ServiceObj = Nothing