Home   Index   About
Ultimate Pack


Custom Search
Overview
Group
Quick Info

Windows NT
Yes
Win95
No
Win32s
No
Import Library
netapi32.lib
Header File
lmaccess.h
Unicode
WinNT
Platform Notes
All LanMan APIs are UNICODE only

NetUserAdd

The NetUserAdd function adds a user account and assigns a password and privilege level.

Security Requirements

Only members of the Administrators or Account Operators local group can successfully execute NetUserAdd. Only members of the Administrators local group can add an Administrators privilege account.

NET_API_STATUS NetUserAdd(

LPWSTR servername,

DWORD level,

LPBYTE buf,

LPDWORD parm_err

);

Parameters

servername

Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.

level

Specifies one of the following values to set the level of information provided.

Value
Meaning

The buf parameter points to a USER_INFO_1 structure.

The buf parameter points to a USER_INFO_2 structure.

The buf parameter points to a USER_INFO_3 structure.

buf

Pointer to the buffer in which the data set with the level parameter is stored.

parm_err

Optional pointer to a DWORD that contains the index of the first parameter that causes ERROR_INVALID_PARAMETER. If NULL, the parameter is not returned on error.

Return Values

If the function returns account information, the return value is NERR_Success.

If the function fails, the return value is one of the following error codes.

Value
Meaning
ERROR_ACCESS_DENIED
The user does not have access to the requested information.
NERR_InvalidComputer
Thiecomputer name is invalid.
NERR_NotPrimary
The operation is allowed only on the primary domain controller of the domain.
NERR_GroupExists
The group already exists.
NERR_UserExists
The user account already exists.
NERR_PasswordTooShort
The password is shorter than required.

Remarks

Server users must use a system in which the server creates a WINDOWS NT system account for the new user. The creation of this account is controlled by several parameters in the server's LANMAN.INI file.

If the newly added server user name already exists as a Windows NT system user, the useril_home_dir member of the USER_INFO_1 structure is ignored. The NetUserAdd function supports USER_INFO_1 and USER_INFO_2 structures. Using members of USER_INFO_1 initializes default values in USER_INFO_2 and USER_INFO_3 structures.

Subsequent NetUserSetInfo calls can change the default values. The following are possible default values.

Member
Default Value
usriX_auth_flags
None (0)
usriX_full_name
usri1_name
usriX_usr_comment
None (null string)
usriX_parms
None (null string)
usriX_workstations
All (null string)
usriX_acct_expires
Never (TIMEQ_FOREVER)
usriX_max_storage
Unlimited (USER_MAXSTORAGE_UNLIMITED)
usriX_logon_hours
Logon allowed at any time (each element 0xFF; all bits set to 1)
usriX_logon_server
Any domain controller (\\*)
usriX_country_code
Current (country_code on the server
usriX_code_page
0

See Also

NetUserEnum
, NetUserSetInfo, NetUserDel


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2011 Free Tech Secrets ;) greatis just4fun network just4fun