Platform SDK: Network Management |
The NetUnjoinDomain function unjoins a computer from a workgroup or a domain.
Unjoining (and joining) a computer to a domain or workgroup can be performed only by a member of the Administrators local group on the target computer. If you call the NetUnjoinDomain function remotely, you must supply credentials because you cannot delegate credentials under these circumstances.
NET_API_STATUS NetUnjoinDomain( LPCWSTR lpServer, LPCWSTR lpAccount, LPCWSTR lpPassword, DWORD fUnjoinOptions );
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes or one of the Win32 error codes.
Value | Meaning |
---|---|
ERROR_INVALID_PARAMETER | A parameter is incorrect. |
NERR_SetupNotJoined | The computer is not currently joined to a domain. |
NERR_SetupDomainController | This computer is a domain controller and cannot be unjoined from a domain. |
Different processes, or different threads of the same process, should not call the NetUnjoinDomain function at the same time. This situation can leave the computer in an inconsistent state.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Lmjoin.h; include Lm.h.
Library: Use Netapi32.lib.
Network Management Overview, Network Management Functions, NetJoinDomain, NetRenameMachineInDomain