HOWTO: Use NetUserAdd
ID: Q140165
|
The information in this article applies to:
-
Microsoft Win32 Software Development Kit (SDK), versions 3.1, 3.5, 3.51, 4.0
-
Microsoft Windows 2000
SUMMARY
NetUserAdd allows a Windows NT application to add a user to a Windows NT
workstation or server programmatically. Adding a user with this function
seems easy enough, but there are a few issues that are not obvious.
MORE INFORMATION
If you would like to add users to a Windows NT workstation or server in
your application, you must use NetUserAdd. Given a server name, level, and
appropriate structure, a new user will be created. The following pointers
may help you avoid problems:
- As required of all Net* functions, submit all strings in UNICODE (wide
characters). Use MultiByteToWideChar to convert standard ASCII strings
into UNICODE strings. Don't forget to include the terminating NULL in
string conversions.
- Specify the server name as \\server. Be sure to include double
backslashes, four backslashes if inside a C literal string.
- Use the UF_SCRIPT required flag. Without it, you will get
ERROR_INVALID_PARAMETER.
- When using level 2, make sure your strings do not exceed the maximum
lengths. Constants are defined for the maximum lengths. For example, the
maximum lengths for params, comment, user comment, and full name is
MAXCOMMENTSZ. Paths must fit within PATHLEN characters. UNC names for
servers must fit in UNCLEN characters.
- Use NetUserAdd only to add user accounts, not guest or administrator
accounts. After the account is established, use NetUserSetGroups to add
Administrator, Guest, or other groups to the new user account.
REFERENCES
Microsoft LAN Manager, A Programmer's Guide by Ralph Ryan.
Microsoft LAN Manager Programmer's Reference.
Win32 SDK Documentation.
Additional query words:
NETUSERADD LANMAN
Keywords : kbnetwork kbNTOS310 kbNTOS350 kbNTOS351 kbSDKPlatform kbWinOS95 kbNetAPI kbGrpNet
Version : WINDOWS:3.1,3.5,3.51,4.0
Platform : WINDOWS
Issue type : kbhowto
|