Article ID: 238388 - Last Review: September 28, 2007 - Revision: 2.2

PRB: Cannot Set the Service Account Name Through ADSI

This article was previously published under Q238388
Expand all | Collapse all

SYMPTOMS

Using Microsoft Active Directory Services Interfaces (ADSI), you cannot change the ServiceAccountName property on an IADsService object.

When SetInfo is called on a Microsoft Windows 2000 client or on a Microsoft Windows NT client, although no error is reported, the changes are not made on the target server.

On Microsoft Windows XP, you receive the following error when you try to set the ServiceAccountName property:
Active Directory: The specified directory property is not supported

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article.

MORE INFORMATION

To work around this limitation in ADSI, use Windows Management Instrumentation (WMI) to access resources and management information.

WMI is a system component on WIndows 2000, Microsoft WIndows Server 2003 and Windows XP. To use WMI on Microsoft WIndows NT 4, install the core runtime from the following MSDN Web site:
Windows Management Instumentation (WMI) CORE 1.5 (Windows NT 4.0)
http://www.microsoft.com/downloads/details.aspx?FamilyID=c174cfb1-ef67-471d-9277-4c2b1014a31e&DisplayLang=en (http://www.microsoft.com/downloads/details.aspx?FamilyID=c174cfb1-ef67-471d-9277-4c2b1014a31e&DisplayLang=en)
The following sample code 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 more information about Windows Management Instrumentation (WMI), visit the following MSDN Web site:
http://msdn.microsoft.com/downloads/default.asp?URL=/code/topic.asp?URL=/MSDN-FILES/028/000/015/topic.xml (http://msdn.microsoft.com/downloads/default.asp?URL=/code/topic.asp?URL=/MSDN-FILES/028/000/015/topic.xml)

For more information about Active Directory Services Interfaces (ADSI), visit the following Microsoft web site:
http://msdn2.microsoft.com/library/aa772170.aspx (http://msdn2.microsoft.com/library/aa772170.aspx)

APPLIES TO
  • Microsoft Active Directory Service Interfaces 2.5
Keywords: 
kbdswmanage2003swept kbprb KB238388
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations