LoginToFileServer
Logs an object in to the server
#include <nwconn.h>
int LoginToFileServer (
char *objectName,
WORD objectType,
char *objectPassword);
A server name can be supplied as part of the objectName: serverName/ objectName
The following table lists return values and descriptions.
If a server name is supplied as part of the objectName, an attempt is made to log in to the specified server. If successful, the new server is assigned a file server ID. The file server ID is made the current file server number, and the connection number on the new server is made the current connection. Any logins using LoginToFileServer without specifying a new server name result in a login to the current server. If the login is not to the current server, the current working volume and current working path are set to the root.
To determine the connection number assigned to the NLM as a result of calling the LoginToFileServer function, an NLM can call GetCurrentConnection (defined in nwcntask.h) or GetConnectionNumber.
NOTE:LoginToFileServer establishes a single connection to the specified server. However, LogoutFromFileServer logs out all the connections to the specified server. You can use LogoutObject to log out a single connection.
LoginObject, Logout, LogoutFromFileServer, LogoutObject
#include <stdio.h>
#include <stdlib.h>
#include <nwconn.h>
main()
{
int c;
if(LoginToFileServer("supervisor",OT_USER,""))
{
printf("could not login\r\n");
getch();
return 1;
}
c = GetCurrentConnection();
printf("current connection: %d\r\n",c);
getch();
LogoutObject(c);
printf("logout performed\r\n");
getch();
ReturnConnection(c); /* Only need to return connection
if logged into local server */
printf("connection returned\r\n");
}