Purpose
NetServerNameAdd adds a secondary server computername to a server allowing network requests directed to the secondary server name to be received and processed by the server.
Syntax
#include netcons.h> #include server.h>
NetServerNameAdd
Parameters
pszServerName (const UCHAR LSFAR*) input
Returns
ulrc (APIRET) returns for 32 bit
NetServerNameAdd or Net32ServerNameAdd returns one of the following values
52
Remarks
The maximum number of names a server can support is defined by the manifest SV_MAX_SRV_NAMES in server.h.
The machine must also be properly configured for the additional Netbios names required as specified by the names parameter on the NETx= line of the IBMLAN.INI file.
This API can be called from OS/2 workstations. Administrative or server operator authority is required to call this API.
Related Functions
Example Code
This example adds a servername called Server18 , then enumerates the server names in use and finally removes the Server18 servername.
#define PURE_32#define INCL_DOS
#define INCL_DOSERRORS
#include os2.h>
#include stdio.h>
#include stdlib.h>
#include string.h>
#include netcons.h>
#include server.h>
int main(VOID)
{
struct server_info_0 LSFAR * pBuffer; /* pointer to enum return info */
ULONG ulBufLen=4096; /* length in bytes of enum buffer */
ULONG ulLevel=0; /* enum return info level */
ULONG ulEntriesRead=0; /* total entries read from enum */
ULONG ulEntriesAvail=0; /* total entries available from enum */
CHAR achServer[CNLEN+1]; /* remote server name or '\0' */
CHAR achName[CNLEN+1]; /* server name to add and delete */
ULONG ulReturnCode=0; /* return code */
strcpy(achName,"Server18"); /* initialize servername to use */
achServer[0] = '\0'; /* initialize for local API call */
ulReturnCode = Net32ServerNameAdd(achServer,achName);
if (ulReturnCode == NO_ERROR)
{
if ((pBuffer = malloc(ulBufLen)) != NULL)
{
ulReturnCode = Net32ServerNameEnum(achServer,
ulLevel,
(unsigned char *)pBuffer,
ulBufLen,
ulEntriesRead,
ulEntriesAvail);
if (ulReturnCode == NO_ERROR || ulReturnCode == ERROR_MORE_DATA)
{
printf("Total entries read == %u\n",ulEntriesRead);
printf("Total entries available == %u\n",ulEntriesAvail);
printf("Server names are \n");
while (ulEntriesRead) {
printf("\t%s\n",pBuffer->sv0_name); /* print out name */
pBuffer++; /* advance to next entry */
ulEntriesRead--; /* dec entries displayed */
} /* endwhile */
}
else
{
printf("Net32ServerNameEnum() error return code = %u.\n",
ulReturnCode);
Net32ServerNameDel(achServer,achName);
return 1;
}
} else {
printf("malloc() failed!\n");
return 1;
}
ulReturnCode = Net32ServerNameDel(achServer,achName);
if (ulReturnCode != NO_ERROR)
{
printf("Net32ServerNameDel() error return code = %u.\n",
ulReturnCode);
return 1;
}
}
else
{
printf("Net32ServerNameAdd() error return code = %u.\n",
ulReturnCode);
return 1;
}
return NO_ERROR;
}