PRB: Unable to Set the Service Account Name Through ADSI

ID: Q238388


The information in this article applies to:
  • Microsoft Active Directory Service Interfaces, versions 2.0, 2.5


SYMPTOMS

Using Active Directory Services Interfaces(ADSI), the ServiceAccountName property can be altered on a IADsService object. When SetInfo is called there is no error reported, however, the changes are not made on the target server.


STATUS

Microsoft is aware of this problem in the products listed at the beginning of this article.


MORE INFORMATION

In order to work around this limitation in ADSI, Windows Management Instrumentation (WMI) can be used. WMI provides a way to access resources and management information across the enterprise. In order to use the WMI you will need to install the core runtime from the following link:

http://msdn.microsoft.com/developer/sdk/wmisdk/download.asp

The following is a sample script that uses WMI to change the service account name:

   strServiceName = "<Service Name>"  'This is the display name of the service
   strStartName = "<DOMAIN>\<Username>"
   strStartPassword = "<password>"

   Set WServices =    GetObject("WinMgmts:{impersonationLevel=impersonate}!root/cimv2")
   s = "Win32_Service.Name=""" & strServiceName & """"

   Set TheService = WServices.Get(s)
   Set method = TheService.Methods_("Change")
   Set inParam = method.InParameters.SpawnInstance_()
   inParam.StartName = strStartName
   inParam.StartPassword = strStartPassword
   Set outParam = TheService.ExecMethod_("Change", inParam)

   If outParam.returnValue = 0 Then
       MsgBox ("Method executed successfully")
   Else
       MsgBox ("Method failed")
   End If
    
   Set method = Nothing
   Set inParam = Nothing
   Set outParam = Nothing
   Set TheService = Nothing
   Set WServices = Nothing 


REFERENCES

For additional information on Windows Management Instrumentation (WMI), please see the following Web site:

http://msdn.microsoft.com/developer/sdk/wmisdk/default.asp

For additional information on Active Directory Services Interfaces(ADSI), please see the following web site:
http://www.microsoft.com/adsi

Additional query words:

Keywords : kbADSI kbGrpPlatform kbDSupport
Version : winnt:2.0,2.5
Platform : winnt
Issue type : kbprb


Last Reviewed: September 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.