[DllImport("netapi32.dll", CharSet=CharSet.Unicode)]
static extern int NetJoinDomain(
string lpServer,
string lpDomain,
string lpAccountOU,
string lpAccount,
string lpPassword,
int fJoinOptions);
Declare Function NetJoinDomain Lib "Netapi32.dll" _
(ByVal lpServer As String, _
ByVal lpDomain As String, _
ByVal lpAccountOU As String, _
ByVal lpAccount As String, _
ByVal lpPassword As String, _
ByVal fJoinOptions As Integer) As Integer
[Flags]
public enum JoinOptions
{
NETSETUP_JOIN_DOMAIN = 0x00000001,
NETSETUP_ACCT_CREATE = 0x00000002,
NETSETUP_ACCT_DELETE = 0x00000004,
NETSETUP_WIN9X_UPGRADE = 0x00000010,
NETSETUP_DOMAIN_JOIN_IF_JOINED = 0x00000020,
NETSETUP_JOIN_UNSECURE = 0x00000040,
NETSETUP_MACHINE_PWD_PASSED = 0x00000080,
NETSETUP_DEFER_SPN_SET = 0x10000000
}
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 system error codes.
Return code Description:
To join a machine to a domain the same way that netdom.exe does, use the flags NETSETUP_JOIN_DOMAIN and NETSETUP_ACCT_CREATE. (I determined this by using a debugger to watch which flags netdom used.)
Please add some!
Do you know one? Please contribute it!