Export (0) Print
Expand All
Expand Minimize

NetServerSetInfo function

The NetServerSetInfo function sets a server's operating parameters; it can set them individually or collectively. The information is stored in a way that allows it to remain in effect after the system has been reinitialized.

Syntax


NET_API_STATUS NetServerSetInfo(
  _In_   LPWSTR servername,
  _In_   DWORD level,
  _In_   LPBYTE buf,
  _Out_  LPDWORD ParmError
);

Parameters

servername [in]

Pointer to a string that specifies the name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.

level [in]

Specifies the information level of the data. This parameter can be one of the following values.

ValueMeaning
101

Specifies the server name, type, and associated software. The buf parameter points to a SERVER_INFO_101 structure.

102

Specifies the server name, type, associated software, and other attributes. The buf parameter points to a SERVER_INFO_102 structure.

402

Specifies detailed information about the server. The buf parameter points to a SERVER_INFO_402 structure.

403

Specifies detailed information about the server. The buf parameter points to a SERVER_INFO_403 structure.

 

In addition, levels 1001-1006, 1009-1011, 1016-1018, 1021, 1022, 1028, 1029, 1037, and 1043 are valid based on the restrictions for LAN Manager systems.

buf [in]

Pointer to a buffer that receives the server information. The format of this data depends on the value of the level parameter. For more information, see Network Management Function Buffers.

ParmError [out]

Pointer to a value that receives the index of the first member of the server information structure that causes the ERROR_INVALID_PARAMETER error. If this parameter is NULL, the index is not returned on error. For more information, see the following Remarks section.

Return value

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.

Return codeDescription
ERROR_ACCESS_DENIED

The user does not have access to the requested information.

ERROR_INVALID_LEVEL

The value specified for the level parameter is invalid.

ERROR_INVALID_PARAMETER

The specified parameter is invalid. For more information, see the following Remarks section.

ERROR_NOT_ENOUGH_MEMORY

Insufficient memory is available.

 

Remarks

Only members of the Administrators or Server Operators local group can successfully execute the NetServerSetInfo function.

If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management server functions. For more information, see IADsComputer.

If the NetServerSetInfo function returns ERROR_INVALID_PARAMETER, you can use the ParmError parameter to indicate the first member of the server information structure that is invalid. (A server information structure begins with SERVER_INFO_ and its format is specified by the level parameter.) The following table lists the values that can be returned in the ParmError parameter and the corresponding structure member that is in error. (The prefix sv*_ indicates that the member can begin with multiple prefixes, for example, sv101_ or sv402_.)

ValueMember
SV_PLATFORM_ID_PARMNUMsv*_platform_id
SV_NAME_PARMNUMsv*_name
SV_VERSION_MAJOR_PARMNUMsv*_version_major
SV_VERSION_MINOR_PARMNUMsv*_version_minor
SV_TYPE_PARMNUMsv*_type
SV_COMMENT_PARMNUMsv*_comment
SV_USERS_PARMNUMsv*_users
SV_DISC_PARMNUMsv*_disc
SV_HIDDEN_PARMNUMsv*_hidden
SV_ANNOUNCE_PARMNUMsv*_announce
SV_ANNDELTA_PARMNUMsv*_anndelta
SV_USERPATH_PARMNUMsv*_userpath
SV_ULIST_MTIME_PARMNUMsv*_ulist_mtime
SV_GLIST_MTIME_PARMNUMsv*_glist_mtime
SV_ALIST_MTIME_PARMNUMsv*_alist_mtime
SV_ALERTS_PARMNUMsv*_alerts
SV_SECURITY_PARMNUMsv*_security
SV_NUMADMIN_PARMNUMsv*_numadmin
SV_LANMASK_PARMNUMsv*_lanmask
SV_GUESTACC_PARMNUMsv*_guestacc
SV_CHDEVQ_PARMNUMsv*_chdevq
SV_CHDEVJOBS_PARMNUMsv*_chdevjobs
SV_CONNECTIONS_PARMNUMsv*_connections
SV_SHARES_PARMNUMsv*_shares
SV_OPENFILES_PARMNUMsv*_openfiles
SV_SESSOPENS_PARMNUMsv*_sessopens
SV_SESSVCS_PARMNUMsv*_sessvcs
SV_SESSREQS_PARMNUMsv*_sessreqs
SV_OPENSEARCH_PARMNUMsv*_opensearch
SV_ACTIVELOCKS_PARMNUMsv*_activelocks
SV_NUMREQBUF_PARMNUMsv*_numreqbuf
SV_SIZREQBUF_PARMNUMsv*_sizreqbuf
SV_NUMBIGBUF_PARMNUMsv*_numbigbuf
SV_NUMFILETASKS_PARMNUMsv*_numfiletasks
SV_ALERTSCHED_PARMNUMsv*_alertsched
SV_ERRORALERT_PARMNUMsv*_erroralert
SV_LOGONALERT_PARMNUMsv*_logonalert
SV_ACCESSALERT_PARMNUMsv*_accessalert
SV_DISKALERT_PARMNUMsv*_diskalert
SV_NETIOALERT_PARMNUMsv*_netioalert
SV_MAXAUDITSZ_PARMNUMsv*_maxauditsz
SV_SRVHEURISTICS_PARMNUMsv*_srvheuristics
SV_TIMESOURCE_PARMNUMsv*_timesource

 

Examples

The following code sample demonstrates how to call the NetServerSetInfo function. The sample calls NetServerSetInfo, specifying the level parameter as 1005 (required) to set the sv1005_comment member of the SERVER_INFO_1005 structure.


#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")

#include <stdio.h>
#include <windows.h> 
#include <lm.h>

int wmain(int argc, wchar_t *argv[])
{
   DWORD dwLevel = 1005;
   SERVER_INFO_1005 si;
   NET_API_STATUS nStatus;

   if (argc != 3)
   {
      fwprintf(stderr, L"Usage: %s \\\\ServerName Comment\n", argv[0]);
      exit(1);
   }
   //
   // Fill in SERVER_INFO_1005 structure member.
   //
   si.sv1005_comment = (LPTSTR) argv[2];
   //
   // Call the NetServerSetInfo function, 
   //  specifying level 1005.
   //
   nStatus = NetServerSetInfo(argv[1],
                              dwLevel,
                              (LPBYTE)&si,
                              NULL);
   //
   // Display the result of the call.
   //
   if (nStatus == NERR_Success)
      fwprintf(stderr, L"Comment reset\n", argv[2]);
   else
      fprintf(stderr, "A system error has occurred: %d\n", nStatus);
   return 0;
}


Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Lmserver.h (include Lm.h)

Library

Netapi32.lib

DLL

Netapi32.dll

See also

Network Management Overview
Network Management Functions
Server Functions
NetServerGetInfo
SERVER_INFO_101
SERVER_INFO_102
SERVER_INFO_402
SERVER_INFO_403

 

 

Community Additions

ADD
Show:
© 2014 Microsoft