Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
netunjoindomain (netapi32)
TODO - a short description

C# Signature:

[DllImport("netapi32.dll", SetLastError=true, CharSet = CharSet.Auto)]
static extern int NetUnjoinDomain(
    string lpServer,
    string lpAccount,
    string lpPassword,
    UnJoinOptions fUnjoinOptions

C# User-Defined Types:

public enum UnJoinOptions
    NONE = 0x00000000,
    NETSETUP_ACCT_DELETE = 0x00000004

VB.NET Signature:

    <DllImport("netapi32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
    Private Shared Function NetUnjoinDomain( _
      ByVal lpServer As String, _
      ByVal lpAccount As String, _
      ByVal lpPassword As String, _
      ByVal fUnJoinOptions As UnJoinOptions) As Integer
    End Function

VB.NET User-Defined Types:

    Private Enum UnJoinOptions
      None = 0
    End Enum

Alternative Managed API:

Do you know one? Please contribute it!


lpServer - (in) Pointer to a constant string that specifies the DNS or NetBIOS name of the computer on which the function is to execute. If this parameter is NULL, the local computer is used.

lpAccount - (in) Pointer to a constant string that specifies the account name to use when connecting to the domain controller. The string must specify either a domain NetBIOS name and user account (for example, "REDMOND\user") or the user principal name (UPN) of the user in the form of an Internet-style login name (for example, ""). If this parameter is NULL, the caller's context is used.

lpPassword - (in) If the lpAccount parameter specifies an account name, this parameter must point to the password to use when connecting to the domain controller. Otherwise, this parameter must be NULL.

fUnjoinOptions - (in) Specifies the unjoin options. If this parameter is NETSETUP_ACCT_DELETE, the account is disabled when the unjoin occurs. Note that this option does not delete the account. Currently, there are no other unjoin options defined.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version