CTelnetClient::Login Method  
 
BOOL Login(
  LPCTSTR lpszUserName,  
  LPCTSTR lpszPassword  
);

The Login method attempts to authenticate the user and log them in to the current session.

Parameters

lpszUserName
A null-terminated string which specifies the name of the user to authenticate.
lpszPassword
A null-terminated string which specifies the password to be used when authenticating the user. If the user does not require a password, this parameter may be NULL.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Caution: The Telnet protocol transmits all data, including login credentials, in plaintext and does not provide any inherent encryption. While this library supports optional TLS connections for Telnet, secure Telnet servers are rare in practice. This protocol is still supported for compatibility with legacy systems, but it is strongly recommended that you use secure protocols such as SSH whenever possible, especially when connecting over public or untrusted networks. To establish a secure connection to the server using the Secure Shell (SSH) protocol, use the CSshClient class.

This method is used to authenticate a user, logging them into the server. This method is specifically designed to work with most UNIX based servers, and may work with other servers that use a similar login process. The method works by scanning the data stream for a username prompt and then replying with the specified username. If that is successful, it will then scan for a password prompt and provide the specified password. If no recognized prompt is found, or if the server responds with an error indicating that the username or password is invalid, the method will fail.

If the Login method succeeds, the next call to Read by the client will return any welcome message to the user. This is typically followed by a command prompt where the user can enter commands to be executed on the server. The data sent by the server during the login process is discarded and not available when the method returns. If the client requires this information, use the Search method to automate the login process instead.

Because the Login method is designed for UNIX based systems, it may not work with servers running on other operating system platforms such as Windows or VMS. In this case, applications should use the Search method to search for the appropriate login prompts in the data stream.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cstntv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also