> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IXtfUserClient::SigninUserId

> IXtfUserClient::SigninUserId

# IXtfUserClient::SigninUserId

登录一位由用户 ID 指定的用户，并在必要时将该用户添加到主机。

<Info>在此版本中，此方法通过网络将密码文本传递到主机时并未加密。如果这种行为在你的网络环境中令人担忧，请使用 [AddUser](/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/adduser-ixtfuserclient-xtfuser-xbox-windows-m) 方法将用户添加到主机，然后使用主机上的"登录"应用对用户进行登录并存储用户密码。（"登录"应用通过网络发送的密码是加密的。）之后你可以使用此方法在无需传入密码的情况下登录。</Info>

<a id="syntaxSection" />

## 语法

```cpp theme={null}
public:
HRESULT SigninUserId(
         UINT32 userId,
         LPCWSTR password,
         BOOL bStorePassword
)  
```

<a id="ID4E1" />

<a id="parametersSection" />

### 参数

*userId*\
类型：UINT32

用户的用户 ID。

*password*\
类型：LPCWSTR

用于登录的密码。如果主机上已为此用户存储了密码，请传入 `nullptr` 以使用已存储的密码登录。

*bStorePassword*\
类型：BOOL

如果为 TRUE，则将指定的密码保存在主机上以供以后使用。

<a id="ID4EDB" />

<a id="retvalSection" />

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

<a id="remarks" />

<a id="remarksSection" />

## 备注

如果用户已经登录，则调用此方法无效。

此方法可能返回以下错误代码。

| 错误代码       | 含义                           |
| ---------- | ---------------------------- |
| 0x80048823 | 电子邮件地址无效。                    |
| 0x8004882E | 主机上未存储指定用户的密码。你必须在登录操作中提供密码。 |
| 0x80048821 | 为该用户指定的密码无效。                 |
| 0x8015DC16 | 该用户已在另一台主机上登录。               |

若要通过指定电子邮件地址登录用户，请使用 [SigninUser](/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signinuser-ixtfuserclient-xtfuser-xbox-windows-m)。

若要注销用户，请使用 [SignoutUserId](/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signoutuserid-ixtfuserclient-xtfuser-xbox-windows-m) 或 [SignoutUser](/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signoutuser-ixtfuserclient-xtfuser-xbox-windows-m)。

<a id="requirementsSection" />

## 要求

**头文件：** xtfuser.h

**库：** xtfuser.lib

**支持的平台：** Windows（用于 XBOX 主机工具）

<a id="seealsoSection" />

## 另请参阅

[IXtfUserClient 接口](/reference/tools/xtf/xtfuser/classes/IXtfUserClient/ixtfuserclient-xtfuser-xbox-windows-t)


## Related topics

- [IXtfUserClient::SignoutUserId](/zh-CN/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signoutuserid-ixtfuserclient-xtfuser-xbox-windows-m.md)
- [IXtfUserClient::SigninUser](/zh-CN/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signinuser-ixtfuserclient-xtfuser-xbox-windows-m.md)
- [IXtfUserClient::SignoutUser](/zh-CN/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/signoutuser-ixtfuserclient-xtfuser-xbox-windows-m.md)
- [IXtfUserClient::AddUser Method](/zh-CN/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/adduser-ixtfuserclient-xtfuser-xbox-windows-m.md)
- [IXtfUserClient::DeleteUserId](/zh-CN/reference/tools/xtf/xtfuser/classes/IXtfUserClient/methods/deleteuserid-ixtfuserclient-xtfuser-xbox-windows-m.md)
