IWSManConnectionOptions::get_UserName method (wsmandisp.h)
Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name for authentication. If no value is supplied and the WSManFlagCredUsernamePassword flag is not set, then the user name of the account that is running the script is used.
If the WSManFlagCredUsernamePassword flag is set but no user name is specified, the script prompts the user to enter the user name and password. If no user name and password are entered then an access denied error is returned. For more information, see Authentication for Remote Connections.
This property is read/write.
Syntax
HRESULT get_UserName(
BSTR *name
);
Parameters
name
Return value
None
Remarks
You can supply UserName and Password for a domain account when using Negotiate or Kerberos authentication, or for a local account with Basic authentication. To connect to a local account, the WSMan.CreateSession flags must contain the combination of the WSManFlagUseBasic flag and the WsmanFlagCredUserNamePassword flag. To connect to a domain account, the WSMan.CreateSession flags must contain the combination of the WSManFlagUseNegotiate flag and the WsmanFlagCredUserNamePassword flag, or the combination of the WSManFlagUseKerberos flag and the WsmanFlagCredUserNamePassword flag. For a domain account, UserName must be specified in the form "computer\username", where the "computer" part of the string can be either the name or the IP address. For more information, see Authentication for Remote Connections.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | wsmandisp.h |
Library | WSManDisp.tlb |
DLL | WSMAuto.dll |