0 out of 2 rated this helpful - Rate this topic

UnjoinDomainOrWorkgroup method of the Win32_ComputerSystem Class

Applies to: desktop apps only

The UnjoinDomainOrWorkgroup method removes a computer system from a domain or workgroup.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax

uint32 UnjoinDomainOrWorkgroup(
  [in]  string Password,
  [in]  string UserName,
  [in]  uint32 FUnjoinOptions = 0
);

Parameters

Password [in]

If the UserName parameter specifies an account name, the Password parameter must point to the password to use when connecting to the domain controller. Otherwise, this parameter must be NULL.

Note  Password must use a high authentication level, not less than RPC_C_AUTHN_LEVEL_PKT_PRIVACY, when connecting to Winmgmt or CoSetProxyBlanket on the IWbemServices pointer. If local to Winmgmt, this is not a concern.

UserName [in]

Pointer to a constant null-terminated character string that specifies the account name to use when connecting to the domain controller. Must specify a domain NetBIOS name and user account, for example, domain\user. If this parameter is NULL, the caller context is used.

Windows Server 2003 and Windows XP:  Using the user principal name (UPN) in the form of user@domain is also supported.

Note  UserName must use a high authentication level, not less than RPC_C_AUTHN_LEVEL_PKT_PRIVACY, when connecting to Winmgmt or CoSetProxyBlanket on the IWbemServices pointer. If local to Winmgmt, this is not a concern.

FUnjoinOptions [in]

Set of bit flags defining the unjoin options.

ValueMeaning
0

Default. No options.

NETSETUP_ACCT_DELETE
2

Disable the Active Directory account after the unjoin operation, but do not delete the account.

 

Remarks

After calling this method, restart the affected computer to apply the changes.

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Namespace

\root\CIMV2

MOF

Cimwin32.mof

DLL

Cimwin32.dll

See also

Win32_ComputerSystem

 

 

Send comments about this topic to Microsoft

Build date: 3/9/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Putting this together
The 1004 error you are getting is a standard Windows "Invalid Flags" error. I received it too when using the 2 value, but had success when using 4. This suggests that kaok is correct and the value for NETSETUP_ACCT_DELETE is indeed 4
NETSETUP_ACCT_DELETE value

#define NETSETUP_ACCT_DELETE 0x00000004

see. LMJoin.h

Error codes
It would be nice to list what all the error codes are.
For instance, I'm getting 1004 returned. Just what is the error? Why is it being returned rather than 0? How do I solve it?