Platform SDK: Active Directory, ADSI, and Directory Services |
The IADsServiceOperations::SetPassword method sets the password for the account used by the service manager. This method is called when the security context for this service is created.
HRESULT IADsServiceOperations::SetPassword( BSTR bstrNewPassword );
This method supports the standard return values, including S_OK. For other return values, see ADSI Error Codes.
The property IADsService::get_ServiceAccountName identifies the account for which this password is to be set.
The following Visual Basic code snippet shows how to set a password for the Microsoft Fax Service on a Windows 2000 Professional.
Dim cp As IADsComputer Dim so As IADsServiceOperations Dim s as IADsService Set cp = GetObject("WinNT://myMachine,computer") Set so = cp.GetObject("Service", "Fax") so.SetPassword "myPasswd" set s = so MsgBox "The password for " & so.name & " has been changed on " & s.ServiceAccountName
The following C++ code snippet sets the password for the Microsoft Fax Service running on a Windows 2000 Professional.
IADsContainer *pCont; IADsServiceOperations *pSrvOp; LPWSTR adsPath = L"WinNT://myMachine,computer"; HRESULT hr = ADsGetObject(adsPath, IID_IADsContainer, (void**)&pCont); if(FAILED(hr)) exit(hr); IDispatch *pDisp; hr = pCont->GetObject(L"Service",L"Fax",&pDisp); pCont->Release(); if(FAILED(hr)) exit(hr); hr = pDisp->QueryInterface(IID_IADsServiceOperations,(void**)&pSrvOp); pDisp->Release(); if(FAILED(hr)) exit(hr); hr = pSrvOp->SetPassword(L"myPassword"); pSrvOp->Release();
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with DSClient).
Windows 95/98: Requires Windows 95 or later (with DSClient).
Header: Declared in Iads.h.
IADsService, IADsService::get_ServiceAccountName, IADsServiceOperations