NWSMTSConnectToTargetService

Connects an engine to a specified Target Service.

Syntax

  #include <smsutapi.h> 
  #include <smstsapi.h> 
   
  CCODE NWSMTSConnectToTargetService (
     UINT32  *connection, 
     STRING   targetServiceName, 
     STRING   targetUserName, 
     void    *authentication);
  

Parameters

connection

(IN/OUT) Specifies a pointer to the connection information from NWSMConnectToTSA. Outputs a pointer to the connection to the Target Service in addition to the input information.

targetServiceName

(IN) Specifies the Target Service name returned by NWSMTSScanTargetServiceName or NWSMTSListTargetServices.

targetUserName

(IN) Specifies the user name on a file server (maximum size is NWSM_MAX_TARGET_USER_NAME_LEN).

authentication

(IN) Points to the authentication necessary to establish a connection with the Target Service (for example, a user password).

Return Values

See Section 9.3, Target Service Return Values for more information.

The following table lists the return values associated with the function.

0x00000000

Successful

0xFFFDFFB9

NWSMTS_UNSUPPORTED_FUNCTION

0xFFFDFFC9

NWSMTS_OUT_OF_MEMORY

0xFFFDFFD7

NWSMTS_LOGIN_DENIED

0xFFFDFFF9

NWSMTS_CREATE_ERROR

0xFFFEFFF2

NWSMDR_INVALID_PROTOCOL

0xFFFEFFFD

NWSMDR_OUT_OF_MEMORY

0xFFFEFFE0

NWSMDR_CORRUPTED_STATE

0xFFFEFFE9

NWSMDR_INVALID_CONTEXT

0xFFFEFFFE

NWSMDR_INVALID_PARAMETER

0xFFFEFFFF

NWSMDR_INVALID_CONNECTION

0xFFFDFFAE

NWSMTS_CLUSTER_TARGET_HAS_NO_VOLUMES

Remarks

Before NWSMTSConnectToTargetService is called, the engine must be connected to a TSA that has access to the desired target.

targetServiceName should contain a Target Service name from the name list returned by NWSMTSListTargetServices.

NWSMTSConnectToTargetService connects an engine to the specified Target Service and establishes the user's rights on the Target Service. After successfully connecting, the engine can access the Target Service’s data.

An engine can connect to only one Target Service per TSA connection. This means that a Target Service can have multiple connections, but each connection must be referenced by a different TSA connection.

targetUserName contains the user name that allows proper access to the Target Service’s data. For NetWare 3.x and earlier names, these are the bindery names. For NetWare 4.0 and later, these are directory names. For Linux file system TSA it is the user name of a user having an identity on the Linux system.

authentication is an unencrypted, length preceded (UINT16) string. However, the SMDR encrypt/decrypts it if it is passed between SMDRs. If no authentication is passed, set the length to zero. Do not pass a NULL pointer.

See Also

NWSMConnectToTSA, NWSMTSScanTargetServiceName, NWSMTSListTargetServices

Example

  #include <smstsapi.h>
  #include <smsdrapi.h>
  
  UINT32   connection;
  STRING   TSAName ;
  NWSM_NAME_LIST *serviceNameList = NULL;
  char   targetServiceName[NWSM_MAX_TARGET_SRVC_NAME_LEN],
       targetUserName[NWSM_MAX_TARGET_USER_NAME_LEN], 
         authentication[30];
  
  /* Connect to the TSA. */
  NWSMConnectToTSA(TSAName, &connection);
  
  /* Find Target Service through the connected TSA. */
  sprintf(targetServiceName, "%s%s", TSAName, ".*");
  NWSMTSListTargetServices(connection, targetServiceName , &serviceNameList);
  
  /* Set up the authentication. */
  sprintf(&authentication[2], "%s", "Password");
  *((UINT16 *)&authentication[0]) = strlen(&authentication[2]);
  
  /* Connect to the Target Service. */
  NWSMTSConnectToTargetService(&connection, (STRING)serviceNameList->name, (STRING)targetUserName, authentication);