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

# XUserFindUserByLocalId

> XUserFindUserByLocalId

Retrieves a handle to the user for a specific local user ID.

## Syntax

```cpp theme={null}
HRESULT XUserFindUserByLocalId(  
         XUserLocalId userLocalId,  
         XUserHandle* handle  
)  
```

### Parameters

*userLocalId*   \_In\_\
Type: [XUserLocalId](https://docs.xbox.com/reference/system/xuser/structs/xuserlocalid.md)

The local ID to get the user for.

*handle*   \_Out\_\
Type: XUserHandle\*

Contains a handle to the user associated with a specific local user ID.

### Return value

> [!NOTE]
>
> This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).

Type: HRESULT

HRESULT success or error code.

| Return Code | Description |
| - | - |
| S\_OK | The operation succeeded. |
| HRESULT\_FROM\_WIN32(ERROR\_NOT\_FOUND) | The user was not found. |

## Remarks

For each **XUserHandle** handle that you retrieve from an **XUser** API, inluding **XUserFindUserByLocalId**, you must
close that handle calling [XUserCloseHandle](https://docs.xbox.com/reference/system/xuser/functions/xuserclosehandle.md). The reference count of the handle increases after calling Get / Find functions.

To retrieve a handle to a user for a specific local user ID, call XUserFindUserByLocalId.

To retrieve the XBOX User ID (XUID) for a local user, call [XUserFindUserById](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbyid.md).

To retrieve a user ID for a specific device ID, call [XUserFindForDevice](https://docs.xbox.com/reference/system/xuser/functions/xuserfindfordevice.md).

## Requirements

**Header:** XUser.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, Steam Deck, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XUser](https://docs.xbox.com/reference/system/xuser/xuser_members.md)

[XUserFindUserById](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbyid.md)

[XUserFindForDevice](https://docs.xbox.com/reference/system/xuser/functions/xuserfindfordevice.md)


## Related topics

- [XUserFindUserById](https://docs.xbox.com/reference/system/xuser/functions/xuserfinduserbyid.md)
- [XUserLocalId](https://docs.xbox.com/reference/system/xuser/structs/xuserlocalid.md)
- [XUserGetId](https://docs.xbox.com/reference/system/xuser/functions/xusergetid.md)
- [XUser (API contents)](https://docs.xbox.com/reference/system/xuser/xuser_members.md)
- [Using C# wrappers for GDK APIs in your Unity project](https://docs.xbox.com/build/gdk-and-engines/unity/unity-api-wrappers.md)
