IWSMan::CreateSession method (wsmandisp.h)
Creates a Session object that can then be used for subsequent network operations.
HRESULT CreateSession( [in] BSTR connection, [in] long flags, [in] IDispatch *connectionOptions, [out] IDispatch **session );
The protocol and service to connect to, including either IPv4 or IPv6. The format of the connection information is as follows: <Transport><Address><Suffix>. For examples, see Remarks. If no connection information is provided, the local computer is used.
The session flags that specify the authentication method, such as Negotiate authentication or Digest authentication, for connecting to a remote computer. These flags also specify other session connection information, such as encoding or encryption. This parameter must contain one or more of the flags in __WSManSessionFlags for a remote connection. For more information, see Session Constants. No flag settings are required for a connection to the WinRM service on the local computer.
If no authentication flags are specified, Kerberos is used unless one of the following conditions is true, in which case Negotiate is used:
- explicit credentials are supplied and the destination host is trusted
- the destination host is "localhost", "127.0.0.1" or "[::1]"
- the client computer is in a workgroup and the destination host is trusted
A pointer to an IWSManConnectionOptions object that contains a user name and password. The default is NULL.
A pointer to a new IWSManSession object.
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
The following list contains examples of formats used to specify connection information in the connection parameter (when creating an HTTPS session, the <Address> field must match the server computer certificate name, otherwise a failure occurs):
Uses HTTPS to connect to the default web service location.
Uses HTTPS to connect to the specific web service location.
Uses HTTPS and IPv6 with the default port.
Uses HTTPS and IPv6 with the given port.
|Minimum supported client||Windows Vista|
|Minimum supported server||Windows Server 2008|