Microsoft KB Archive/238388

{|
 * width="100%"|

PRB: Unable to Set the Service Account Name Through ADSI

 * }

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 has confirmed this to be a problem in the Microsoft products that are 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/downloads/default.asp?URL=/code/topic.asp?URL=/MSDN-FILES/028/000/015/topic.xml" The following is a sample script that uses WMI to change the service account name:

  strServiceName = ""  'This is the display name of the service strStartName = "\" strStartPassword = " "

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