Purpose
NetServerNameDel removes a secondary server computername from a server and removes all shares and closes all sessions established to that name.
Syntax
#include netcons.h> #include server.h>
NetServerNameDel
Parameters
pszServerName(const UCHAR LSFAR*) input
Returns
ulrc (APIRET) returns FOR 32 bit
NetServerNameDel or Net32ServerNameDel returns one of the following values
53
Remarks
Only secondary server names can be deleted by the API. An attempt to delete the primary server name will result in NERR_DelPrimaryName being returned.
If a name successfully deleted had sessions to it, then the name may still show in NetServerNameEnum and may not be re-added until the server has completed closing all sessions established to that name.
Any shares that were added to the deleted name will also be removed.
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; }