The Win32 Network Management APIs 16

 

 

 

 

 

Setting the User Flags, Level 1008 Code Snippet Example

 

The following code fragment illustrates how to set user flags with a call to the NetUserSetInfo() function. The USER_INFO_1008 topic contains a list of valid values for the flags and a description of each flag. Note that the UF_SCRIPT flag must be set for Windows NT, Windows 2000, Windows XP, and LAN Manager networks. Trying to set other flags without setting UF_SCRIPT on these networks will cause the NetUserSetInfo() function to fail.

 

#define USR_FLAGS UF_SCRIPT | UF_NORMAL_ACCOUNT

USER_INFO_1008 usriFlags;

// Set the usri1008_flags member to the appropriate constant value.

// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.

usriFlags.usri1008_flags = USR_FLAGS;

netRet = NetUserSetInfo( SERVER, USERNAME, 1008, (LPBYTE)&usriFlags, NULL );

if( netRet == NERR_Success )

    wprintf(L"Success with level 1008!\n");

else

    wprintf(L"ERROR: %d returned from NetUserSetInfo level 1008\n", netRet);

 

Setting the User Script Path, Level 1009 Code Snippet Example

 

The following code fragment illustrates how to set the path for the logon script file of a particular user with a call to the NetUserSetInfo() function. The script file can be a .CMD file, an .EXE file, or a .BAT file. The string can also be null. The USER_INFO_1009 topic contains additional information.

 

#define SCRIPT_PATH L"C:\\BIN\\MYSCRIPT.BAT"

USER_INFO_1009 usriScrPath;

// Set the usri1009_script_path member to a valid Unicode string.

// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.

usriScrPath.usri1009_script_path = SCRIPT_PATH;

netRet = NetUserSetInfo( SERVER, USERNAME, 1009, (LPBYTE)&usriScrPath, NULL );

if( netRet == NERR_Success )

    wprintf(L"Success with level 1009!\n");

else

    wprintf(L"ERROR: %d returned from NetUserSetInfo level 1009\n", netRet);

 

Setting The User Authority Flags, Level 1010 Code Snippet Example

 

The following code fragment illustrates how to set the operator privilege flags for a user with a call to the NetUserSetInfo() function. The USER_INFO_1010 topic contains a list of valid values for the flags and a description of each flag.

 

#define AUTHORITY_FLAGS AF_OP_ACCOUNTS

USER_INFO_1010 usriAuthFlags;

// Set the usri1010_auth_flags member to the appropriate constant value.

// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.

usriAuthFlags.usri1010_auth_flags = AUTHORITY_FLAGS;

netRet = NetUserSetInfo( SERVER, USERNAME, 1010, (LPBYTE)&usriAuthFlags, NULL);

if(netRet == NERR_Success)

    wprintf(L"Success with level 1010!\n");

else

    wprintf(L"ERROR: %d returned from NetUserSetInfo level 1010\n", netRet);

 

Setting The User Full Name, Level 1011 Code Snippet Example

 

The following code fragment illustrates how to set a user's full name with a call to the NetUserSetInfo() function. The USER_INFO_1011 topic contains additional information.

 

#define USER_FULL_NAME L"Joe B. User"

USER_INFO_1011 usriFullName;

// Set the usri1011_full_name member to a valid Unicode string.

// SERVER and USERNAME can be hard-coded strings or pointers to Unicode strings.

usriFullName.usri1011_full_name = USER_FULL_NAME;

netRet = NetUserSetInfo( SERVER, USERNAME, 1011, (LPBYTE)&usriFullName, NULL);

if(netRet == NERR_Success)

    wprintf(L"Success with level 1011!\n");

else

    wprintf(L"ERROR: %d returned from NetUserSetInfo\n", netRet);

 

 

 

 

< Win32 Network Management APIs 15 | Win32 Network Management APIs | Win32 Programming | Win32 Network Management APIs 17 >