NetGetJoinableOUs
The NetGetJoinableOUs function retrieves a list of organizational units (OUs) in which a computer account can be created.
Security Requirements
No special group membership is required to successfully execute the NetGetJoinableOUs function.
NET_API_STATUS NetGetJoinableOUs(
LPCWSTR lpServer,
LPCWSTR lpDomain,
LPCWSTR lpAccount,
LPCWSTR lpPassword,
DWORD *OUCount,
LPWSTR **OUs
);
Parameters
- lpServer
- [in] Pointer to a constant null-terminated Unicode character string that specifies the name of the computer on which to call the function. The string must begin with \\. If this parameter is NULL, the local computer is used.
- lpDomain
- [in] Pointer to a constant null-terminated Unicode character string that specifies the name of the domain for which to retrieve the list of OUs that can be joined.
- lpAccount
- [in] Pointer to a constant null-terminated Unicode character 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, "someone@microsoft.com"). 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.
- OUCount
- [out] Receives the count of OUs returned in the list of joinable OUs.
- OUs
- [out] Pointer to an array that receives the list of joinable OUs. This array is allocated by the system and must be freed using a single call to the NetApiBufferFree function.
Return Values
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_NOT_ENOUGH_MEMORY |
Not enough storage is available to process this command. |
NERR_DefaultJoinRequired |
The destination domain controller does not support creating computer accounts in OUs. |
Remarks
For more information about organizational units, see Managing Users in the Active Directory documentation.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Lmjoin.h; include Lm.h.
Library: Use Netapi32.lib.
See Also
Network Management Overview, Network Management Functions, NetGetJoinInformation