Setting the User Comment (Description) Field, Level 1007 Code Snippet Example
The following code fragment illustrates how to associate a comment with a user by calling the NetUserSetInfo() function. The USER_INFO_1007 topic contains additional information.
#define COMMENT LThis is my Comment Text for the user
USER_INFO_1007 usriComment;
// Set the usri1007_comment member to point to a valid Unicode string.
// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.
usriComment.usri1007_comment = COMMENT;
netRet = NetUserSetInfo( SERVER, USERNAME, 1007, (LPBYTE)&usriComment, NULL );
if( netRet == NERR_Success )
wprintf(LSuccess with level 1007!\n);
else
wprintf(LERROR: %d returned from NetUserSetInfo level 1007\n, netRet);
A working sample program is given below. Firstly we are going to verify the user description setting before we run the program. In this case we just using a local user, mike spoon on the computer named nazuri.

Next we create a new empty Win32 console application project.

Then, add the source file and give it a suitable name.

Then, add the following source code.
#include <windows.h>
// INCL_NET includes all LAN Manager headers if necessary
// #define INCL_NET
#include <lm.h>
#include <stdio.h>
// Optionally, use the following #pragma if you do not include
// the library through the Visual Studio setting
// example: #pragma comment(linker, <linker options>)
#pragma comment(lib, netapi32.lib)
// In this case, we are testing the local user
#define SERVER Lnazuri
#define USERNAME Lmike spoon
#define COMMENT LThis is my Comment Text for the user
int wmain()
{
DWORD netRet;
USER_INFO_1007 usriComment;
// Set the usri1007_comment member to point to a valid Unicode string.
// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.
usriComment.usri1007_comment = COMMENT;
netRet = NetUserSetInfo(SERVER, USERNAME, 1007, (LPBYTE)&usriComment, NULL);
if(netRet == NERR_Success)
wprintf(LSuccess with level 1007!\n);
else
wprintf(LERROR: %d returned from NetUserSetInfo() level 1007\n, netRet);
return 0;
}
Build and run the project.

Verify the action. The description has been changed as shown below.

