1# OsAccount
2
3
4## Overview
5
6Provides APIs for managing system accounts.
7
8**Since**: 12
9
10
11## Summary
12
13
14### Files
15
16| Name | Description |
17| -------- | -------- |
18| [os_account.h](os__account_8h.md) | Defines the APIs for accessing and managing system account information. |
19| [os_account_common.h](os__account__common_8h.md) | Defines common types used in **OsAccount** APIs. |
20
21
22### Types
23
24| Name | Description |
25| -------- | -------- |
26| typedef enum [OsAccount_ErrCode](#osaccount_errcode-1) [OsAccount_ErrCode](#osaccount_errcode) | Defines an enum for error codes. |
27
28
29### Enums
30
31| Name | Description |
32| -------- | -------- |
33| [OsAccount_ErrCode](#osaccount_errcode-1) {<br>OS_ACCOUNT_ERR_OK = 0,<br>OS_ACCOUNT_ERR_INTERNAL_ERROR = 12300001,<br>OS_ACCOUNT_ERR_INVALID_PARAMETER = 12300002<br>} | Enumerates the error codes. |
34
35
36### Functions
37
38| Name | Description |
39| -------- | -------- |
40| [OsAccount_ErrCode](#osaccount_errcode) [OH_OsAccount_GetName](#oh_osaccount_getname) (char \*buffer, size_t buffer_size) | Obtains the name of the system account, to which the caller process belongs. |
41
42
43## Type Description
44
45
46### OsAccount_ErrCode
47
48```
49typedef enum OsAccount_ErrCode OsAccount_ErrCode
50```
51
52**Description**
53
54Defines an enum for error codes.
55
56**Since**: 12
57
58
59## Enum Description
60
61
62### OsAccount_ErrCode
63
64```
65enum OsAccount_ErrCode
66```
67
68**Description**
69
70Enumerates the error codes.
71
72**Since**: 12
73
74| Value | Description |
75| -------- | -------- |
76| OS_ACCOUNT_ERR_OK | Operation successful. |
77| OS_ACCOUNT_ERR_INTERNAL_ERROR | Internal error. |
78| OS_ACCOUNT_ERR_INVALID_PARAMETER | Invalid parameter. |
79
80
81## Function Description
82
83
84### OH_OsAccount_GetName()
85
86```
87OsAccount_ErrCode OH_OsAccount_GetName (char *buffer, size_t buffer_size)
88```
89
90**Description**
91
92Obtains the name of the system account, to which the caller process belongs.
93
94**System capability**: SystemCapability.Account.OsAccount
95
96**Since**: 12
97
98**Parameters**
99
100| Name | Description |
101| -------- | -------- |
102| buffer | Pointer to the system account name, which including the name of the maximum length (**LOGIN_NAME_MAX**) and the end character ('\0'). |
103| buffer_size | Length of the system account name. |
104
105**Returns**
106
107Returns **OS_ACCOUNT_ERR_OK** if the operation is successful.<br>Returns **OS_ACCOUNT_ERR_INTERNAL_ERROR** if an internal error occurred.<br>Returns **OS_ACCOUNT_ERR_INVALID_PARAMETER** if **buffer** is a null pointer or the name length (excluding the end character ('\0')) is greater than or equal to **buffer_size**.
108
109