• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.account.osAccount (系统账号管理)
2
3<!--Kit: Basic Services Kit-->
4<!--Subsystem: Account-->
5<!--Owner: @steven-q-->
6<!--Designer: @JiDong-CS1-->
7<!--Tester: @zhaimengchao-->
8<!--Adviser: @zengyawen-->
9
10本模块提供管理系统账号的基础能力,包括系统账号的添加、删除、查询、设置、订阅、启动等功能。
11
12> **说明:**
13>
14> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
15
16## 导入模块
17
18```ts
19import { osAccount } from '@kit.BasicServicesKit';
20```
21
22## osAccount.getAccountManager
23
24getAccountManager(): AccountManager
25
26获取系统账号管理对象。
27
28**系统能力:** SystemCapability.Account.OsAccount
29
30**返回值:**
31
32| 类型                              | 说明              |
33| --------------------------------- | ---------------- |
34| [AccountManager](#accountmanager) | 系统账号管理对象。 |
35
36**示例:**
37
38  ```ts
39  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
40  ```
41
42## OsAccountType
43
44表示系统账号类型的枚举。
45
46**系统能力:** SystemCapability.Account.OsAccount47
48| 名称   | 值 | 说明         |
49| ------ | ------ | ----------- |
50| ADMIN  | 0      | 管理员账号。 |
51| NORMAL | 1      | 普通账号。   |
52| GUEST  | 2      | 访客账号。   |
53
54## AccountManager
55
56系统账号管理类。
57
58### checkMultiOsAccountEnabled<sup>9+</sup>
59
60checkMultiOsAccountEnabled(callback: AsyncCallback&lt;boolean&gt;): void
61
62判断是否支持多系统账号。使用callback异步回调。
63
64**系统能力:** SystemCapability.Account.OsAccount
65
66**参数:**
67
68| 参数名   | 类型                         | 必填 | 说明                                                     |
69| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
70| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示支持多系统账号;返回false表示不支持。 |
71
72**错误码:**
73
74以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
75
76| 错误码ID | 错误信息             |
77| -------- | ------------------- |
78| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
79| 12300001 | The system service works abnormally. |
80
81**示例:**
82
83  ```ts
84  import { BusinessError } from '@kit.BasicServicesKit';
85  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
86  try {
87    accountManager.checkMultiOsAccountEnabled((err: BusinessError, isEnabled: boolean) => {
88      if (err) {
89        console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
90      } else {
91      console.info('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
92      }
93    });
94  } catch (err) {
95    const err = err as BusinessError;
96    console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
97  }
98  ```
99
100### checkMultiOsAccountEnabled<sup>9+</sup>
101
102checkMultiOsAccountEnabled(): Promise&lt;boolean&gt;
103
104判断是否支持多系统账号。使用Promise异步回调。
105
106**系统能力:** SystemCapability.Account.OsAccount
107
108**返回值:**
109
110| 类型                   | 说明                                                        |
111| :--------------------- | :--------------------------------------------------------- |
112| Promise&lt;boolean&gt; | Promise对象。返回true表示支持多系统账号;返回false表示不支持。 |
113
114**错误码:**
115
116以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
117
118| 错误码ID | 错误信息             |
119| -------- | ------------------- |
120| 12300001 | The system service works abnormally. |
121
122**示例:**
123
124  ```ts
125  import { BusinessError } from '@kit.BasicServicesKit';
126  try {
127    let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
128    accountManager.checkMultiOsAccountEnabled().then((isEnabled: boolean) => {
129      console.info('checkMultiOsAccountEnabled successfully, isEnabled: ' + isEnabled);
130    }).catch((err: BusinessError) => {
131      console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
132    });
133  } catch (err) {
134    const err = err as BusinessError;
135    console.error(`checkMultiOsAccountEnabled failed, code is ${err.code}, message is ${err.message}`);
136  }
137  ```
138
139### checkOsAccountActivated<sup>(deprecated)</sup>
140
141checkOsAccountActivated(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
142
143判断指定系统账号是否处于激活状态。使用callback异步回调。
144
145> **说明:**
146>
147> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
148
149**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
150
151**系统能力:** SystemCapability.Account.OsAccount
152
153**参数:**
154
155| 参数名   | 类型                         | 必填 | 说明                                                     |
156| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
157| localId  | number                       | 是   | 系统账号ID。                                             |
158| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示账号已激活;返回false表示账号未激活。 |
159
160**错误码:**
161
162以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
163
164| 错误码ID | 错误信息             |
165| -------- | ------------------- |
166| 201 | Permission denied.|
167| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
168| 12300001 | The system service works abnormally. |
169| 12300002 | Invalid localId.    |
170| 12300003 | Account not found. |
171
172**示例:** 判断ID为100的系统账号是否处于激活状态
173
174  ```ts
175  import { BusinessError } from '@kit.BasicServicesKit';
176  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
177  let localId: number = 100;
178  try {
179    accountManager.checkOsAccountActivated(localId, (err: BusinessError, isActivated: boolean) => {
180      if (err) {
181        console.error(`checkOsAccountActivated failed, code is ${err.code}, message is ${err.message}`);
182      } else {
183        console.info('checkOsAccountActivated successfully, isActivated:' + isActivated);
184      }
185    });
186  } catch (err) {
187    const err = err as BusinessError;
188    console.error(`checkOsAccountActivated exception: code is ${err.code}, message is ${err.message}`);
189  }
190  ```
191
192### checkOsAccountActivated<sup>(deprecated)</sup>
193
194checkOsAccountActivated(localId: number): Promise&lt;boolean&gt;
195
196判断指定系统账号是否处于激活状态。使用Promise异步回调。
197
198> **说明:**
199>
200> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
201
202**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
203
204**系统能力:** SystemCapability.Account.OsAccount
205
206**参数:**
207
208| 参数名  | 类型   | 必填 | 说明                               |
209| ------- | ------ | ---- | --------------------------------- |
210| localId | number | 是   | 系统账号ID。 |
211
212**返回值:**
213
214| 类型                   | 说明                                                       |
215| ---------------------- | ---------------------------------------------------------- |
216| Promise&lt;boolean&gt; | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 |
217
218**错误码:**
219
220以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
221
222| 错误码ID | 错误信息             |
223| -------- | ------------------- |
224| 201 | Permission denied.|
225| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
226| 12300001 | The system service works abnormally. |
227| 12300002 | Invalid localId.    |
228| 12300003 | Account not found. |
229
230**示例:** 判断ID为100的系统账号是否处于激活状态
231
232  ```ts
233  import { BusinessError } from '@kit.BasicServicesKit';
234  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
235  let localId: number = 100;
236  try {
237    accountManager.checkOsAccountActivated(localId).then((isActivated: boolean) => {
238      console.info('checkOsAccountActivated successfully, isActivated: ' + isActivated);
239    }).catch((err: BusinessError) => {
240      console.error(`checkOsAccountActivated failed, code is ${err.code}, message is ${err.message}`);
241    });
242  } catch (err) {
243    const err = err as BusinessError;
244    console.error(`checkOsAccountActivated exception: code is ${err.code}, message is ${err.message}`);
245  }
246  ```
247
248### isOsAccountConstraintEnabled<sup>11+</sup>
249
250isOsAccountConstraintEnabled(constraint: string): Promise&lt;boolean&gt;
251
252判断当前系统账号是否使能指定约束。使用Promise异步回调。
253
254**系统能力:** SystemCapability.Account.OsAccount
255
256**参数:**
257
258| 参数名     | 类型   | 必填 | 说明                                |
259| ---------- | ------ | ---- | ---------------------------------- |
260| constraint | string | 是   | 指定的[约束](#系统账号约束列表)名称。 |
261
262**返回值:**
263
264| 类型                   | 说明                                                                  |
265| --------------------- | --------------------------------------------------------------------- |
266| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
267
268**错误码:**
269
270以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
271
272| 错误码ID | 错误信息             |
273| -------- | ------------------- |
274| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
275| 12300001 | The system service works abnormally. |
276
277**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
278
279  ```ts
280  import { BusinessError } from '@kit.BasicServicesKit';
281  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
282  let constraint: string = 'constraint.wifi';
283  try {
284    accountManager.isOsAccountConstraintEnabled(constraint).then((isEnabled: boolean) => {
285      console.info('isOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
286    }).catch((err: BusinessError) => {
287      console.error(`isOsAccountConstraintEnabled failed, code is ${err.code}, message is ${err.message}`);
288    });
289  } catch (err) {
290    const err = err as BusinessError;
291    console.error(`isOsAccountConstraintEnabled exception: code is ${err.code}, message is ${err.message}`);
292  }
293  ```
294
295### checkOsAccountConstraintEnabled<sup>(deprecated)</sup>
296
297checkOsAccountConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void
298
299判断指定系统账号是否具有指定约束。使用callback异步回调。
300
301> **说明:**
302>
303> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
304
305**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
306
307**系统能力:** SystemCapability.Account.OsAccount
308
309**参数:**
310
311| 参数名     | 类型                         | 必填 | 说明                                                               |
312| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
313| localId    | number                       | 是   | 系统账号ID。                                 |
314| constraint | string                       | 是   | 指定的[约束](#系统账号约束列表)名称。                                |
315| callback   | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
316
317**错误码:**
318
319以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
320
321| 错误码ID | 错误信息             |
322| -------- | ------------------- |
323| 201 | Permission denied.|
324| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
325| 12300001 | The system service works abnormally. |
326| 12300002 | Invalid localId or constraint.    |
327| 12300003 | Account not found. |
328
329**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
330
331  ```ts
332  import { BusinessError } from '@kit.BasicServicesKit';
333  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
334  let localId: number = 100;
335  let constraint: string = 'constraint.wifi';
336  try {
337    accountManager.checkOsAccountConstraintEnabled(localId, constraint, (err: BusinessError, isEnabled: boolean)=>{
338      if (err) {
339        console.error(`checkOsAccountConstraintEnabled failed, code is ${err.code}, message is ${err.message}`);
340      } else {
341        console.info('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
342      }
343    });
344  } catch (err) {
345    const err = err as BusinessError;
346    console.error(`checkOsAccountConstraintEnabled exception: code is ${err.code}, message is ${err.message}`);
347  }
348  ```
349
350### checkOsAccountConstraintEnabled<sup>(deprecated)</sup>
351
352checkOsAccountConstraintEnabled(localId: number, constraint: string): Promise&lt;boolean&gt;
353
354判断指定系统账号是否具有指定约束。使用Promise异步回调。
355
356> **说明:**
357>
358> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
359
360**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
361
362**系统能力:** SystemCapability.Account.OsAccount
363
364**参数:**
365
366| 参数名     | 类型   | 必填 | 说明                                |
367| ---------- | ------ | ---- | ---------------------------------- |
368| localId    | number | 是   | 系统账号ID。  |
369| constraint | string | 是   | 指定的[约束](#系统账号约束列表)名称。 |
370
371**返回值:**
372
373| 类型                   | 说明                                                                  |
374| --------------------- | --------------------------------------------------------------------- |
375| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
376
377**错误码:**
378
379以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
380
381| 错误码ID | 错误信息             |
382| -------- | ------------------- |
383| 201 | Permission denied.|
384| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
385| 12300001 | The system service works abnormally. |
386| 12300002 | Invalid localId or constraint.    |
387| 12300003 | Account not found. |
388
389**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
390
391  ```ts
392  import { BusinessError } from '@kit.BasicServicesKit';
393  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
394  let localId: number = 100;
395  let constraint: string = 'constraint.wifi';
396  try {
397    accountManager.checkOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => {
398      console.info('checkOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
399    }).catch((err: BusinessError) => {
400      console.error(`checkOsAccountConstraintEnabled failed, code is ${err.code}, message is ${err.message}`);
401    });
402  } catch (err) {
403    const err = err as BusinessError;
404    console.error(`checkOsAccountConstraintEnabled exception: code is ${err.code}, message is ${err.message}`);
405  }
406  ```
407
408### checkOsAccountTestable<sup>9+</sup>
409
410checkOsAccountTestable(callback: AsyncCallback&lt;boolean&gt;): void
411
412检查当前系统账号是否为测试账号。使用callback异步回调。
413
414**系统能力:** SystemCapability.Account.OsAccount
415
416**参数:**
417
418| 参数名   | 类型                         | 必填 | 说明                                                                   |
419| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
420| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
421
422**错误码:**
423
424以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
425
426| 错误码ID | 错误信息             |
427| -------- | ------------------- |
428| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
429| 12300001 | The system service works abnormally. |
430
431**示例:**
432
433  ```ts
434  import { BusinessError } from '@kit.BasicServicesKit';
435  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
436  try {
437    accountManager.checkOsAccountTestable((err: BusinessError, isTestable: boolean) => {
438      if (err) {
439        console.error(`checkOsAccountTestable failed, code is ${err.code}, message is ${err.message}`);
440      } else {
441        console.info('checkOsAccountTestable successfully, isTestable: ' + isTestable);
442      }
443    });
444  } catch (err) {
445    const err = err as BusinessError;
446    console.error(`checkOsAccountTestable code is ${err.code}, message is ${err.message}`);
447  }
448  ```
449
450### checkOsAccountTestable<sup>9+</sup>
451
452checkOsAccountTestable(): Promise&lt;boolean&gt;
453
454检查当前系统账号是否为测试账号。使用Promise异步回调。
455
456**系统能力:** SystemCapability.Account.OsAccount
457
458**返回值:**
459
460| 类型                   | 说明                                                                      |
461| ---------------------- | ------------------------------------------------------------------------ |
462| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
463
464**错误码:**
465
466以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
467
468| 错误码ID | 错误信息             |
469| -------- | ------------------- |
470| 12300001 | The system service works abnormally. |
471
472**示例:**
473
474  ```ts
475  import { BusinessError } from '@kit.BasicServicesKit';
476  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
477  try {
478    accountManager.checkOsAccountTestable().then((isTestable: boolean) => {
479      console.info('checkOsAccountTestable successfully, isTestable: ' + isTestable);
480    }).catch((err: BusinessError) => {
481      console.error(`checkOsAccountTestable failed, code is ${err.code}, message is ${err.message}`);
482    });
483  } catch (err) {
484    const err = err as BusinessError;
485    console.error(`checkOsAccountTestable exception: code is ${err.code}, message is ${err.message}`);
486  }
487  ```
488
489### isOsAccountUnlocked<sup>11+</sup>
490
491isOsAccountUnlocked(): Promise&lt;boolean&gt;
492
493检查当前系统账号是否已认证解锁。使用Promise异步回调。
494
495**系统能力:** SystemCapability.Account.OsAccount
496
497**返回值:**
498
499| 类型                   | 说明                                                                      |
500| ---------------------- | ------------------------------------------------------------------------ |
501| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
502
503**错误码:**
504
505以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
506
507| 错误码ID | 错误信息             |
508| -------- | ------------------- |
509| 12300001 | The system service works abnormally. |
510
511**示例:**
512
513  ```ts
514  import { BusinessError } from '@kit.BasicServicesKit';
515  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
516  try {
517    accountManager.isOsAccountUnlocked().then((isVerified: boolean) => {
518      console.info('isOsAccountUnlocked successfully, isVerified: ' + isVerified);
519    }).catch((err: BusinessError) => {
520      console.error(`isOsAccountUnlocked failed, code is ${err.code}, message is ${err.message}`);
521    });
522  } catch (err) {
523    const err = err as BusinessError;
524    console.error(`isOsAccountUnlocked exception: code is ${err.code}, message is ${err.message}`);
525  }
526  ```
527
528### checkOsAccountVerified<sup>(deprecated)</sup>
529
530checkOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
531
532检查当前系统账号是否已认证解锁。使用callback异步回调。
533
534> **说明:**
535>
536> 从API version 9开始支持,从API version 11开始废弃。建议使用[isOsAccountUnlocked](#isosaccountunlocked11)替代。
537
538**系统能力:** SystemCapability.Account.OsAccount
539
540**参数:**
541
542| 参数名   | 类型                         | 必填 | 说明                                                            |
543| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
544| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
545
546**错误码:**
547
548以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
549
550| 错误码ID | 错误信息             |
551| -------- | ------------------- |
552| 12300001 | The system service works abnormally. |
553
554**示例:**
555
556  ```ts
557  import { BusinessError } from '@kit.BasicServicesKit';
558  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
559  try {
560    accountManager.checkOsAccountVerified((err: BusinessError, isVerified: boolean) => {
561      if (err) {
562        console.error(`checkOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
563      } else {
564        console.info('checkOsAccountVerified successfully, isVerified: ' + isVerified);
565      }
566    });
567  } catch (err) {
568    const err = err as BusinessError;
569    console.error(`checkOsAccountVerified exception: code is ${err.code}, message is ${err.message}`);
570  }
571  ```
572
573### checkOsAccountVerified<sup>(deprecated)</sup>
574
575checkOsAccountVerified(): Promise&lt;boolean&gt;
576
577检查当前系统账号是否已认证解锁。使用Promise异步回调。
578
579> **说明:**
580>
581> 从API version 9开始支持,从API version 11开始废弃。建议使用[isOsAccountUnlocked](#isosaccountunlocked11)替代。
582
583**系统能力:** SystemCapability.Account.OsAccount
584
585**返回值:**
586
587| 类型                   | 说明                                                                      |
588| ---------------------- | ------------------------------------------------------------------------ |
589| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
590
591**错误码:**
592
593以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
594
595| 错误码ID | 错误信息             |
596| -------- | ------------------- |
597| 12300001 | The system service works abnormally. |
598
599**示例:**
600
601  ```ts
602  import { BusinessError } from '@kit.BasicServicesKit';
603  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
604  try {
605    accountManager.checkOsAccountVerified().then((isVerified: boolean) => {
606      console.info('checkOsAccountVerified successfully, isVerified: ' + isVerified);
607    }).catch((err: BusinessError) => {
608      console.error(`checkOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
609    });
610  } catch (err) {
611    const err = err as BusinessError;
612    console.error(`checkOsAccountVerified exception: code is ${err.code}, message is ${err.message}`);
613  }
614  ```
615
616### checkOsAccountVerified<sup>(deprecated)</sup>
617
618checkOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
619
620检查指定系统账号是否已验证。使用callback异步回调。
621
622> **说明:**
623>
624> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
625
626**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
627
628**系统能力:** SystemCapability.Account.OsAccount
629
630**参数:**
631
632| 参数名   | 类型                         | 必填 | 说明                                                            |
633| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
634| localId  | number                       | 是   | 系统账号ID。                              |
635| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
636
637**错误码:**
638
639以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
640
641| 错误码ID | 错误信息             |
642| -------- | ------------------- |
643| 201 | Permission denied.|
644| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
645| 12300001 | The system service works abnormally. |
646| 12300002 | Invalid localId.    |
647| 12300003 | Account not found. |
648
649**示例:**
650
651  ```ts
652  import { BusinessError } from '@kit.BasicServicesKit';
653  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
654  let localId: number = 100;
655  try {
656    accountManager.checkOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
657      if (err) {
658        console.error(`checkOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
659      } else {
660        console.info('checkOsAccountVerified successfully, isVerified: ' + isVerified);
661      }
662    });
663  } catch (err) {
664    const err = err as BusinessError;
665    console.error(`checkOsAccountVerified exception: code is ${err.code}, message is ${err.message}`);
666  }
667  ```
668
669### checkOsAccountVerified<sup>(deprecated)</sup>
670
671checkOsAccountVerified(localId: number): Promise&lt;boolean&gt;
672
673检查指定系统账号是否已验证。使用Promise异步回调。
674
675> **说明:**
676>
677> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
678
679**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
680
681**系统能力:** SystemCapability.Account.OsAccount
682
683**参数:**
684
685| 参数名  | 类型   | 必填 | 说明                                                              |
686| ------- | ------ | ---- | --------------------------------------------------------------- |
687| localId | number | 是   | 系统账号ID。不填则检查当前系统账号是否已验证。 |
688
689**返回值:**
690
691| 类型                   | 说明                                                               |
692| ---------------------- | ----------------------------------------------------------------- |
693| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
694
695**错误码:**
696
697以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
698
699| 错误码ID | 错误信息             |
700| -------- | ------------------- |
701| 201 | Permission denied.|
702| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
703| 12300001 | The system service works abnormally. |
704| 12300002 | Invalid localId.    |
705| 12300003 | Account not found. |
706
707**示例:**
708
709  ```ts
710  import { BusinessError } from '@kit.BasicServicesKit';
711  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
712  let localId: number = 100;
713  try {
714    accountManager.checkOsAccountVerified(localId).then((isVerified: boolean) => {
715      console.info('checkOsAccountVerified successfully, isVerified: ' + isVerified);
716    }).catch((err: BusinessError) => {
717      console.error(`checkOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
718    });
719  } catch (err) {
720    const err = err as BusinessError;
721    console.error(`checkOsAccountVerified exception: code is ${err.code}, message is ${err.message}`);
722  }
723  ```
724
725### getOsAccountCount<sup>9+</sup>
726
727getOsAccountCount(callback: AsyncCallback&lt;number&gt;): void
728
729获取已创建的系统账号数量。使用callback异步回调。
730
731**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
732
733**系统能力:** SystemCapability.Account.OsAccount
734
735**参数:**
736
737| 参数名   | 类型                        | 必填 | 说明                                                                         |
738| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
739| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为已创建的系统账号的数量;否则为错误对象。 |
740
741**错误码:**
742
743以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
744
745| 错误码ID | 错误信息             |
746| -------- | ------------------- |
747| 201 | Permission denied.|
748| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
749| 12300001 | The system service works abnormally. |
750
751**示例:**
752
753  ```ts
754  import { BusinessError } from '@kit.BasicServicesKit';
755  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
756  try {
757    accountManager.getOsAccountCount((err: BusinessError, count: number) => {
758      if (err) {
759        console.error(`getOsAccountCount failed, code is ${err.code}, message is ${err.message}`);
760      } else {
761        console.info('getOsAccountCount successfully, count: ' + count);
762      }
763    });
764  } catch (err) {
765    const err = err as BusinessError;
766    console.error(`getOsAccountCount exception: code is ${err.code}, message is ${err.message}`);
767  }
768  ```
769
770### getOsAccountCount<sup>9+</sup>
771
772getOsAccountCount(): Promise&lt;number&gt;
773
774获取已创建的系统账号数量。使用Promise异步回调。
775
776**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
777
778**系统能力:** SystemCapability.Account.OsAccount
779
780**返回值:**
781
782| 类型                  | 说明                                    |
783| --------------------- | -------------------------------------- |
784| Promise&lt;number&gt; | Promise对象,返回已创建的系统账号的数量。 |
785
786**错误码:**
787
788以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
789
790| 错误码ID | 错误信息             |
791| -------- | ------------------- |
792| 201 | Permission denied.|
793| 12300001 | The system service works abnormally. |
794
795**示例:**
796
797  ```ts
798  import { BusinessError } from '@kit.BasicServicesKit';
799  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
800  try {
801    accountManager.getOsAccountCount().then((count: number) => {
802      console.info('getOsAccountCount successfully, count: ' + count);
803    }).catch((err: BusinessError) => {
804      console.error(`getOsAccountCount failed, code is ${err.code}, message is ${err.message}`);
805    });
806  } catch(err) {
807    console.error(`getOsAccountCount exception: code is ${err.code}, message is ${err.message}`);
808  }
809  ```
810
811### getOsAccountLocalId<sup>9+</sup>
812
813getOsAccountLocalId(callback: AsyncCallback&lt;number&gt;): void
814
815获取当前进程所属的系统账号ID。使用callback异步回调。
816
817**系统能力:** SystemCapability.Account.OsAccount
818
819**参数:**
820
821| 参数名   | 类型                        | 必填 | 说明                                                                           |
822| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
823| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 |
824
825**错误码:**
826
827以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
828
829| 错误码ID | 错误信息             |
830| -------- | ------------------- |
831| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
832| 12300001 | The system service works abnormally. |
833
834**示例:**
835
836  ```ts
837  import { BusinessError } from '@kit.BasicServicesKit';
838  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
839  try {
840    accountManager.getOsAccountLocalId((err: BusinessError, localId: number) => {
841      if (err) {
842        console.error(`getOsAccountLocalId failed, code is ${err.code}, message is ${err.message}`);
843      } else {
844        console.info('getOsAccountLocalId successfully, localId: ' + localId);
845      }
846    });
847  } catch (err) {
848    const err = err as BusinessError;
849    console.error(`getOsAccountLocalId exception: code is ${err.code}, message is ${err.message}`);
850  }
851  ```
852
853### getOsAccountLocalId<sup>9+</sup>
854
855getOsAccountLocalId(): Promise&lt;number&gt;
856
857获取当前进程所属的系统账号ID。使用Promise异步回调。
858
859**系统能力:** SystemCapability.Account.OsAccount
860
861**返回值:**
862
863| 类型                  | 说明                                      |
864| --------------------- | ---------------------------------------- |
865| Promise&lt;number&gt; | Promise对象,返回当前进程所属的系统账号ID。 |
866
867**错误码:**
868
869以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
870
871| 错误码ID | 错误信息             |
872| -------- | ------------------- |
873| 12300001 | The system service works abnormally. |
874
875**示例:**
876
877  ```ts
878  import { BusinessError } from '@kit.BasicServicesKit';
879  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
880  try {
881    accountManager.getOsAccountLocalId().then((localId: number) => {
882      console.info('getOsAccountLocalId successfully, localId: ' + localId);
883    }).catch((err: BusinessError) => {
884      console.error(`getOsAccountLocalId failed, code is ${err.code}, message is ${err.message}`);
885    });
886  } catch (err) {
887    const err = err as BusinessError;
888    console.error(`getOsAccountLocalId exception: code is ${err.code}, message is ${err.message}`);
889  }
890  ```
891
892### getOsAccountLocalIdForUid<sup>9+</sup>
893
894getOsAccountLocalIdForUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
895
896根据uid查询对应的系统账号ID。使用callback异步回调。
897
898**系统能力:** SystemCapability.Account.OsAccount
899
900**参数:**
901
902| 参数名   | 类型                        | 必填 | 说明                                                                    |
903| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
904| uid      | number                      | 是   | 进程uid。                                                              |
905| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 |
906
907**错误码:**
908
909以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
910
911| 错误码ID | 错误信息         |
912| -------- | --------------- |
913| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
914| 12300001 | The system service works abnormally. |
915| 12300002 | Invalid uid.    |
916
917**示例:** 查询值为12345678的uid所属的系统账号的账号ID
918
919  ```ts
920  import { BusinessError } from '@kit.BasicServicesKit';
921  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
922  let uid: number = 12345678;
923  try {
924    accountManager.getOsAccountLocalIdForUid(uid, (err: BusinessError, localId: number) => {
925      if (err) {
926        console.error(`getOsAccountLocalIdForUid failed, code is ${err.code}, message is ${err.message}`);
927      }
928      console.info('getOsAccountLocalIdForUid successfully, localId: ' + localId);
929    });
930  } catch (err) {
931    const err = err as BusinessError;
932    console.error(`getOsAccountLocalIdForUid exception: code is ${err.code}, message is ${err.message}`);
933  }
934  ```
935
936### getOsAccountLocalIdForUid<sup>9+</sup>
937
938getOsAccountLocalIdForUid(uid: number): Promise&lt;number&gt;
939
940根据uid查询对应的系统账号ID。使用Promise异步回调。
941
942**系统能力:** SystemCapability.Account.OsAccount
943
944**参数:**
945
946| 参数名 | 类型   | 必填 | 说明      |
947| ------ | ------ | ---- | --------- |
948| uid    | number | 是   | 进程uid。 |
949
950**返回值:**
951
952| 类型                  | 说明                                     |
953| --------------------- | --------------------------------------- |
954| Promise&lt;number&gt; | Promise对象,返回指定uid对应的系统账号ID。 |
955
956**错误码:**
957
958以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
959
960| 错误码ID | 错误信息       |
961| -------- | ------------- |
962| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
963| 12300001 | The system service works abnormally. |
964| 12300002 | Invalid uid. |
965
966**示例:** 查询值为12345678的uid所属的系统账号ID
967
968  ```ts
969  import { BusinessError } from '@kit.BasicServicesKit';
970  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
971  let uid: number = 12345678;
972  try {
973    accountManager.getOsAccountLocalIdForUid(uid).then((localId: number) => {
974      console.info('getOsAccountLocalIdForUid successfully, localId: ' + localId);
975    }).catch((err: BusinessError) => {
976      console.error(`getOsAccountLocalIdForUid failed, code is ${err.code}, message is ${err.message}`);
977    });
978  } catch (err) {
979    const err = err as BusinessError;
980    console.error(`getOsAccountLocalIdForUid exception: code is ${err.code}, message is ${err.message}`);
981  }
982  ```
983
984### getOsAccountLocalIdForUidSync<sup>10+</sup>
985
986getOsAccountLocalIdForUidSync(uid: number): number
987
988根据uid查询对应的系统账号ID。使用同步方式返回结果。
989
990**系统能力:** SystemCapability.Account.OsAccount
991
992**参数:**
993
994| 参数名 | 类型   | 必填 | 说明      |
995| ------ | ------ | ---- | --------- |
996| uid    | number | 是   | 进程uid。 |
997
998**返回值:**
999
1000| 类型                  | 说明                                     |
1001| --------------------- | --------------------------------------- |
1002| number | 返回指定uid对应的系统账号ID。 |
1003
1004**错误码:**
1005
1006以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1007
1008| 错误码ID | 错误信息       |
1009| -------- | ------------- |
1010| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1011| 12300002 | Invalid uid. |
1012
1013**示例:** 查询值为12345678的uid所属的系统账号ID
1014
1015  ```ts
1016  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1017  let uid: number = 12345678;
1018  try {
1019    let localId : number = accountManager.getOsAccountLocalIdForUidSync(uid);
1020    console.info('getOsAccountLocalIdForUidSync successfully, localId: ' + localId);
1021  } catch (err) {
1022    const err = err as BusinessError;
1023    console.error(`getOsAccountLocalIdForUidSync exception: code is ${err.code}, message is ${err.message}`);
1024  }
1025  ```
1026
1027### getOsAccountLocalIdForDomain<sup>9+</sup>
1028
1029getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
1030
1031根据域账号信息,获取与其关联的系统账号ID。使用callback异步回调。
1032
1033**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1034
1035**系统能力:** SystemCapability.Account.OsAccount
1036
1037**参数:**
1038
1039| 参数名     | 类型                                    | 必填 | 说明                                                                         |
1040| ---------- | --------------------------------------- | ---- | -------------------------------------------------------------------------- |
1041| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。                                                                |
1042| callback   | AsyncCallback&lt;number&gt;             | 是   | 回调函数。如果查询成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 |
1043
1044**错误码:**
1045
1046以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1047
1048| 错误码ID | 错误信息       |
1049| -------- | ------------- |
1050| 201 | Permission denied.|
1051| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1052| 12300001 | The system service works abnormally. |
1053| 12300002 | Invalid domainInfo. |
1054
1055**示例:**
1056
1057  ```ts
1058  import { BusinessError } from '@kit.BasicServicesKit';
1059  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
1060  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1061  try {
1062    accountManager.getOsAccountLocalIdForDomain(domainInfo, (err: BusinessError, localId: number) => {
1063      if (err) {
1064        console.error(`getOsAccountLocalIdForDomain failed, code is ${err.code}, message is ${err.message}`);
1065      } else {
1066        console.info('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
1067      }
1068    });
1069  } catch (err) {
1070    const err = err as BusinessError;
1071    console.error(`getOsAccountLocalIdForDomain exception: code is ${err.code}, message is ${err.message}`);
1072  }
1073  ```
1074
1075### getOsAccountLocalIdForDomain<sup>9+</sup>
1076
1077getOsAccountLocalIdForDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
1078
1079根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。
1080
1081**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1082
1083**系统能力:** SystemCapability.Account.OsAccount
1084
1085**参数:**
1086
1087| 参数名     | 类型                                    | 必填 | 说明         |
1088| ---------- | --------------------------------------- | ---- | ------------ |
1089| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。 |
1090
1091**返回值:**
1092
1093| 类型                  | 说明                                    |
1094| :-------------------- | :------------------------------------- |
1095| Promise&lt;number&gt; | Promise对象,返回域账号关联的系统账号ID。 |
1096
1097**错误码:**
1098
1099以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1100
1101| 错误码ID | 错误信息       |
1102| -------- | ------------- |
1103| 201 | Permission denied.|
1104| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1105| 12300001 | The system service works abnormally. |
1106| 12300002 | Invalid domainInfo. |
1107
1108**示例:**
1109
1110  ```ts
1111  import { BusinessError } from '@kit.BasicServicesKit';
1112  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1113  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
1114  try {
1115    accountManager.getOsAccountLocalIdForDomain(domainInfo).then((localId: number) => {
1116      console.info('getOsAccountLocalIdForDomain successfully, localId: ' + localId);
1117    }).catch((err: BusinessError) => {
1118      console.error(`getOsAccountLocalIdForDomain failed, code is ${err.code}, message is ${err.message}`);
1119    });
1120  } catch (err) {
1121    const err = err as BusinessError;
1122    console.error(`getOsAccountLocalIdForDomain exception: code is ${err.code}, message is ${err.message}`);
1123  }
1124  ```
1125
1126### getOsAccountConstraints<sup>(deprecated)</sup>
1127
1128getOsAccountConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1129
1130获取指定系统账号的全部约束。使用callback异步回调。
1131
1132> **说明:**
1133>
1134> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1135
1136**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1137
1138**系统能力:** SystemCapability.Account.OsAccount
1139
1140**参数:**
1141
1142| 参数名   | 类型                                     | 必填 | 说明                                                                                           |
1143| -------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------- |
1144| localId  | number                                   | 是   | 系统账号ID。                                                                                  |
1145| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是   | 回调函数,如果获取成功,err为null,data为该系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 |
1146
1147**错误码:**
1148
1149以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1150
1151| 错误码ID | 错误信息             |
1152| -------- | ------------------- |
1153| 201 | Permission denied.|
1154| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1155| 12300001 | The system service works abnormally. |
1156| 12300002 | Invalid localId.    |
1157| 12300003 | Account not found. |
1158
1159**示例:** 获取ID为100的系统账号的全部约束
1160
1161  ```ts
1162  import { BusinessError } from '@kit.BasicServicesKit';
1163  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1164  let localId: number = 100;
1165  try {
1166    accountManager.getOsAccountConstraints(localId, (err: BusinessError, constraints: string[]) => {
1167      if (err) {
1168        console.error(`getOsAccountConstraints failed, err: code is ${err.code}, message is ${err.message}`);
1169      } else {
1170        console.info('getOsAccountConstraints successfully, constraints: ' + JSON.stringify(constraints));
1171      }
1172    });
1173  } catch (err) {
1174    const err = err as BusinessError;
1175    console.error(`getOsAccountConstraints exception: code is ${err.code}, message is ${err.message}`);
1176  }
1177  ```
1178
1179### getOsAccountConstraints<sup>(deprecated)</sup>
1180
1181getOsAccountConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
1182
1183获取指定系统账号的全部约束。使用Promise异步回调。
1184
1185> **说明:**
1186>
1187> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1188
1189**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1190
1191**系统能力:** SystemCapability.Account.OsAccount
1192
1193**参数:**
1194
1195| 参数名  | 类型   | 必填 | 说明         |
1196| ------- | ------ | ---- | ------------ |
1197| localId | number | 是   | 系统账号ID。 |
1198
1199**返回值:**
1200
1201| 类型                               | 说明                                                       |
1202| ---------------------------------- | ---------------------------------------------------------- |
1203| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 |
1204
1205**错误码:**
1206
1207以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1208
1209| 错误码ID | 错误信息             |
1210| -------- | ------------------- |
1211| 201 | Permission denied.|
1212| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1213| 12300001 | The system service works abnormally. |
1214| 12300002 | Invalid localId.    |
1215| 12300003 | Account not found. |
1216
1217**示例:** 获取ID为100的系统账号的全部约束
1218
1219  ```ts
1220  import { BusinessError } from '@kit.BasicServicesKit';
1221  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1222  let localId: number = 100;
1223  try {
1224    accountManager.getOsAccountConstraints(localId).then((constraints: string[]) => {
1225      console.info('getOsAccountConstraints, constraints: ' + constraints);
1226    }).catch((err: BusinessError) => {
1227      console.error(`getOsAccountConstraints err: code is ${err.code}, message is ${err.message}`);
1228    });
1229  } catch (e) {
1230    const err = e as BusinessError;
1231    console.error(`getOsAccountConstraints exception: code is ${err.code}, message is ${err.message}`);
1232  }
1233  ```
1234
1235### getActivatedOsAccountLocalIds<sup>9+</sup>
1236
1237getActivatedOsAccountLocalIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
1238
1239查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。
1240
1241**系统能力:** SystemCapability.Account.OsAccount
1242
1243**参数:**
1244
1245| 参数名   | 类型                                     | 必填 | 说明                                                   |
1246| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
1247| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 |
1248
1249**错误码:**
1250
1251以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1252
1253| 错误码ID | 错误信息       |
1254| -------- | ------------- |
1255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
1256| 12300001 | The system service works abnormally. |
1257
1258**示例:**
1259
1260  ```ts
1261  import { BusinessError } from '@kit.BasicServicesKit';
1262  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1263  try {
1264    accountManager.getActivatedOsAccountLocalIds((err: BusinessError, idArray: number[])=>{
1265      if (err) {
1266        console.error(`getActivatedOsAccountLocalIds code is ${err.code}, message is ${err.message}`);
1267      } else {
1268        console.info('getActivatedOsAccountLocalIds idArray length:' + idArray.length);
1269        for(let i=0;i<idArray.length;i++) {
1270          console.info('activated os account id: ' + idArray[i]);
1271        }
1272      }
1273    });
1274  } catch (e) {
1275    const err = e as BusinessError;
1276    console.error(`getActivatedOsAccountLocalIds exception: code is ${err.code}, message is ${err.message}`);
1277  }
1278  ```
1279
1280### getActivatedOsAccountLocalIds<sup>9+</sup>
1281
1282getActivatedOsAccountLocalIds(): Promise&lt;Array&lt;number&gt;&gt;
1283
1284查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。
1285
1286**系统能力:** SystemCapability.Account.OsAccount
1287
1288**返回值:**
1289
1290| 类型                               | 说明                                               |
1291| :--------------------------------- | :------------------------------------------------ |
1292| Promise&lt;Array&lt;number&gt;&gt; | Promise对象,返回当前处于激活状态的系统账号的ID列表。 |
1293
1294**错误码:**
1295
1296以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
1297
1298| 错误码ID | 错误信息       |
1299| -------- | ------------- |
1300| 12300001 | The system service works abnormally. |
1301
1302**示例:**
1303
1304  ```ts
1305  import { BusinessError } from '@kit.BasicServicesKit';
1306  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1307  try {
1308    accountManager.getActivatedOsAccountLocalIds().then((idArray: number[]) => {
1309      console.info('getActivatedOsAccountLocalIds, idArray: ' + idArray);
1310    }).catch((err: BusinessError) => {
1311      console.error(`getActivatedOsAccountLocalIds err: code is ${err.code}, message is ${err.message}`);
1312    });
1313  } catch (e) {
1314    const err = e as BusinessError;
1315    console.error(`getActivatedOsAccountLocalIds exception: code is ${err.code}, message is ${err.message}`);
1316  }
1317  ```
1318
1319### getCurrentOsAccount<sup>(deprecated)</sup>
1320
1321getCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
1322
1323查询当前进程所属的系统账号的信息。使用callback异步回调。
1324
1325> **说明:**
1326>
1327> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1328
1329**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。
1330
1331**系统能力:** SystemCapability.Account.OsAccount
1332
1333**参数:**
1334
1335| 参数名   | 类型                                                 | 必填 | 说明                                           |
1336| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
1337| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 |
1338
1339**错误码:**
1340
1341以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1342
1343| 错误码ID | 错误信息             |
1344| -------- | ------------------- |
1345| 201 | Permission denied. |
1346| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1347| 12300001 | The system service works abnormally. |
1348
1349**示例:**
1350
1351  ```ts
1352  import { BusinessError } from '@kit.BasicServicesKit';
1353  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1354  try {
1355    accountManager.getCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
1356      if (err) {
1357        console.error(`getCurrentOsAccount code is ${err.code}, message is ${err.message}`);
1358      } else {
1359        console.info('getCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
1360      }
1361    });
1362  } catch (e) {
1363    const err = e as BusinessError;
1364    console.error(`getCurrentOsAccount exception: code is ${err.code}, message is ${err.message}`);
1365  }
1366  ```
1367
1368### getCurrentOsAccount<sup>(deprecated)</sup>
1369
1370getCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
1371
1372查询当前进程所属的系统账号的信息。使用Promise异步回调。
1373
1374> **说明:**
1375>
1376> 从API version 9开始支持,从API version 11开始废弃。替代方法仅向系统应用开放。
1377
1378**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>,以上权限仅系统应用可申请。
1379
1380**系统能力:** SystemCapability.Account.OsAccount
1381
1382**返回值:**
1383
1384| 类型                                           | 说明                                       |
1385| ---------------------------------------------- | ----------------------------------------- |
1386| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统账号信息。 |
1387
1388**错误码:**
1389
1390以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1391
1392| 错误码ID | 错误信息             |
1393| -------- | ------------------- |
1394| 201 | Permission denied. |
1395| 12300001 | The system service works abnormally. |
1396
1397**示例:**
1398
1399  ```ts
1400  import { BusinessError } from '@kit.BasicServicesKit';
1401  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1402  try {
1403    accountManager.getCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
1404      console.info('getCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
1405    }).catch((err: BusinessError) => {
1406      console.error(`getCurrentOsAccount err: code is ${err.code}, message is ${err.message}`);
1407    });
1408  } catch (e) {
1409    const err = e as BusinessError;
1410    console.error(`getCurrentOsAccount exception: code is ${err.code}, message is ${err.message}`);
1411  }
1412  ```
1413
1414### getOsAccountType<sup>9+</sup>
1415
1416getOsAccountType(callback: AsyncCallback&lt;OsAccountType&gt;): void
1417
1418查询当前进程所属的系统账号的账号类型。使用callback异步回调。
1419
1420**系统能力:** SystemCapability.Account.OsAccount
1421
1422**参数:**
1423
1424| 参数名   | 类型                                                 | 必填 | 说明                                                 |
1425| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
1426| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 |
1427
1428**错误码:**
1429
1430以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1431
1432| 错误码ID | 错误信息             |
1433| -------- | ------------------- |
1434| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1435| 12300001 | The system service works abnormally. |
1436
1437**示例:**
1438
1439  ```ts
1440  import { BusinessError } from '@kit.BasicServicesKit';
1441  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1442  try {
1443    accountManager.getOsAccountType((err: BusinessError, accountType: osAccount.OsAccountType) => {
1444      if (err) {
1445        console.error(`getOsAccountType err: code is ${err.code}, message is ${err.message}`);
1446      } else {
1447        console.info('getOsAccountType accountType: ' + accountType);
1448      }
1449    });
1450  } catch (e) {
1451    const err = e as BusinessError;
1452    console.error(`getOsAccountType exception: code is ${err.code}, message is ${err.message}`);
1453  }
1454  ```
1455
1456### getOsAccountType<sup>9+</sup>
1457
1458getOsAccountType(): Promise&lt;OsAccountType&gt;
1459
1460查询当前进程所属的系统账号的账号类型。使用Promise异步回调。
1461
1462**系统能力:** SystemCapability.Account.OsAccount
1463
1464**返回值:**
1465
1466| 类型                                           | 说明                                             |
1467| ---------------------------------------------- | ----------------------------------------------- |
1468| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise对象,返回当前进程所属的系统账号的账号类型。 |
1469
1470**错误码:**
1471
1472以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
1473
1474| 错误码ID | 错误信息             |
1475| -------- | ------------------- |
1476| 12300001 | The system service works abnormally. |
1477
1478**示例:**
1479
1480  ```ts
1481  import { BusinessError } from '@kit.BasicServicesKit';
1482  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1483  try {
1484    accountManager.getOsAccountType().then((accountType: osAccount.OsAccountType) => {
1485      console.info('getOsAccountType, accountType: ' + accountType);
1486    }).catch((err: BusinessError) => {
1487      console.error(`getOsAccountType err: code is ${err.code}, message is ${err.message}`);
1488    });
1489  } catch (e) {
1490    const err = e as BusinessError;
1491    console.error(`getOsAccountType exception: code is ${err.code}, message is ${err.message}`);
1492  }
1493  ```
1494
1495### queryDistributedVirtualDeviceId<sup>9+</sup>
1496
1497queryDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
1498
1499获取分布式虚拟设备ID。使用callback异步回调。
1500
1501**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
1502
1503**系统能力:** SystemCapability.Account.OsAccount
1504
1505**参数:**
1506
1507| 参数名   | 类型                        | 必填 | 说明                                                                   |
1508| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
1509| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
1510
1511**错误码:**
1512
1513以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1514
1515| 错误码ID | 错误信息             |
1516| -------- | ------------------- |
1517| 201 | Permission denied.|
1518| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1519| 12300001 | The system service works abnormally. |
1520
1521**示例:**
1522
1523  ```ts
1524  import { BusinessError } from '@kit.BasicServicesKit';
1525  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1526  try {
1527    accountManager.queryDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
1528      if (err) {
1529        console.error(`queryDistributedVirtualDeviceId err: code is ${err.code}, message is ${err.message}`);
1530      } else {
1531        console.info('queryDistributedVirtualDeviceId virtualID: ' + virtualID);
1532      }
1533    });
1534  } catch (e) {
1535    const err = e as BusinessError;
1536    console.error(`queryDistributedVirtualDeviceId exception: code is ${err.code}, message is ${err.message}`);
1537  }
1538  ```
1539
1540### queryDistributedVirtualDeviceId<sup>9+</sup>
1541
1542queryDistributedVirtualDeviceId(): Promise&lt;string&gt;
1543
1544获取分布式虚拟设备ID。使用Promise异步回调。
1545
1546**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
1547
1548**系统能力:** SystemCapability.Account.OsAccount
1549
1550**返回值:**
1551
1552| 类型                  | 说明                              |
1553| --------------------- | --------------------------------- |
1554| Promise&lt;string&gt; | Promise对象,返回分布式虚拟设备ID。 |
1555
1556**错误码:**
1557
1558以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1559
1560| 错误码ID | 错误信息             |
1561| -------- | ------------------- |
1562| 201 | Permission denied.|
1563| 12300001 | The system service works abnormally. |
1564
1565**示例:**
1566
1567  ```ts
1568  import { BusinessError } from '@kit.BasicServicesKit';
1569  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1570  try {
1571    accountManager.queryDistributedVirtualDeviceId().then((virtualID: string) => {
1572      console.info('queryDistributedVirtualDeviceId, virtualID: ' + virtualID);
1573    }).catch((err: BusinessError) => {
1574      console.error(`queryDistributedVirtualDeviceId err: code is ${err.code}, message is ${err.message}`);
1575    });
1576  } catch (e) {
1577    const err = e as BusinessError;
1578    console.error(`queryDistributedVirtualDeviceId exception: code is ${err.code}, message is ${err.message}`);
1579  }
1580  ```
1581
1582### getOsAccountLocalIdForSerialNumber<sup>9+</sup>
1583
1584getOsAccountLocalIdForSerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
1585
1586通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。
1587
1588**系统能力:** SystemCapability.Account.OsAccount
1589
1590**参数:**
1591
1592| 参数名       | 类型                        | 必填 | 说明                                                                           |
1593| ------------ | --------------------------- | ---- | ---------------------------------------------------------------------------- |
1594| serialNumber | number                      | 是   | 账号SN码。                                                                    |
1595| callback     | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 |
1596
1597**错误码:**
1598
1599以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1600
1601| 错误码ID | 错误信息               |
1602| -------- | ------------------- |
1603| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1604| 12300001 | The system service works abnormally. |
1605| 12300002 | Invalid serialNumber. |
1606| 12300003 | The account indicated by serialNumber does not exist. |
1607
1608**示例:** 查询与SN码12345关联的系统账号的ID
1609
1610  ```ts
1611  import { BusinessError } from '@kit.BasicServicesKit';
1612  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1613  let serialNumber: number = 12345;
1614  try {
1615    accountManager.getOsAccountLocalIdForSerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
1616      if (err) {
1617        console.error(`get localId code is ${err.code}, message is ${err.message}`);
1618      } else {
1619        console.info('get localId:' + localId + ' by serialNumber: ' + serialNumber);
1620      }
1621    });
1622  } catch (e) {
1623    const err = e as BusinessError;
1624    console.error(`get localId exception: code is ${err.code}, message is ${err.message}`);
1625  }
1626  ```
1627
1628### getOsAccountLocalIdForSerialNumber<sup>9+</sup>
1629
1630getOsAccountLocalIdForSerialNumber(serialNumber: number): Promise&lt;number&gt;
1631
1632通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。
1633
1634**系统能力:** SystemCapability.Account.OsAccount
1635
1636**参数:**
1637
1638| 参数名       | 类型   | 必填 | 说明       |
1639| ------------ | ------ | ---- | ---------- |
1640| serialNumber | number | 是   | 账号SN码。 |
1641
1642**返回值:**
1643
1644| 类型                  | 说明                                         |
1645| --------------------- | -------------------------------------------- |
1646| Promise&lt;number&gt; | Promise对象,返回与SN码关联的系统账号的账号ID。 |
1647
1648**错误码:**
1649
1650以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1651
1652| 错误码ID | 错误信息               |
1653| -------- | ------------------- |
1654| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1655| 12300001 | The system service works abnormally. |
1656| 12300002 | Invalid serialNumber. |
1657| 12300003 | The account indicated by serialNumber does not exist. |
1658
1659**示例:** 查询与SN码12345关联的系统账号的ID
1660
1661  ```ts
1662  import { BusinessError } from '@kit.BasicServicesKit';
1663  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1664  let serialNumber: number = 12345;
1665  try {
1666    accountManager.getOsAccountLocalIdForSerialNumber(serialNumber).then((localId: number) => {
1667      console.info('getOsAccountLocalIdForSerialNumber localId: ' + localId);
1668    }).catch((err: BusinessError) => {
1669      console.error(`getOsAccountLocalIdForSerialNumber err: code is ${err.code}, message is ${err.message}`);
1670    });
1671  } catch (e) {
1672    const err = e as BusinessError;
1673    console.error(`getOsAccountLocalIdForSerialNumber exception: code is ${err.code}, message is ${err.message}`);
1674  }
1675  ```
1676
1677### getSerialNumberForOsAccountLocalId<sup>9+</sup>
1678
1679getSerialNumberForOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
1680
1681通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。
1682
1683**系统能力:** SystemCapability.Account.OsAccount
1684
1685**参数:**
1686
1687| 参数名   | 类型                        | 必填 | 说明                                                                         |
1688| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
1689| localId  | number                      | 是   | 系统账号ID。                                                                 |
1690| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 |
1691
1692**错误码:**
1693
1694以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1695
1696| 错误码ID | 错误信息             |
1697| -------- | ------------------- |
1698| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1699| 12300001 | The system service works abnormally. |
1700| 12300002 | Invalid localId.    |
1701| 12300003 | Account not found. |
1702
1703**示例:** 获取ID为100的系统账号关联的SN码
1704
1705  ```ts
1706  import { BusinessError } from '@kit.BasicServicesKit';
1707  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1708  let localId: number = 100;
1709  try {
1710    accountManager.getSerialNumberForOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
1711      if (err) {
1712        console.error(`get serialNumber code is ${err.code}, message is ${err.message}`);
1713      } else {
1714        console.info('get serialNumber:' + serialNumber + ' by localId: ' + localId);
1715      }
1716    });
1717  } catch (e) {
1718    const err = e as BusinessError;
1719    console.error(`get serialNumber exception: code is ${err.code}, message is ${err.message}`);
1720  }
1721  ```
1722
1723### getSerialNumberForOsAccountLocalId<sup>9+</sup>
1724
1725getSerialNumberForOsAccountLocalId(localId: number): Promise&lt;number&gt;
1726
1727通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。
1728
1729**系统能力:** SystemCapability.Account.OsAccount
1730
1731**参数:**
1732
1733| 参数名  | 类型   | 必填 | 说明          |
1734| ------- | ------ | ---- | ----------- |
1735| localId | number | 是   | 系统账号ID。 |
1736
1737**返回值:**
1738
1739| 类型                  | 说明                                    |
1740| :-------------------- | :------------------------------------- |
1741| Promise&lt;number&gt; | Promise对象,返回与该系统账号关联的SN码。 |
1742
1743**错误码:**
1744
1745以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
1746
1747| 错误码ID | 错误信息             |
1748| -------- | ------------------- |
1749| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1750| 12300001 | The system service works abnormally. |
1751| 12300002 | Invalid localId.    |
1752| 12300003 | Account not found. |
1753
1754**示例:** 获取ID为100的系统账号关联的SN码
1755
1756  ```ts
1757  import { BusinessError } from '@kit.BasicServicesKit';
1758  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1759  let localId: number = 100;
1760  try {
1761    accountManager.getSerialNumberForOsAccountLocalId(localId).then((serialNumber: number) => {
1762      console.info('getSerialNumberForOsAccountLocalId serialNumber: ' + serialNumber);
1763    }).catch((err: BusinessError) => {
1764      console.error(`getSerialNumberForOsAccountLocalId err: code is ${err.code}, message is ${err.message}`);
1765    });
1766  } catch (e) {
1767    const err = e as BusinessError;
1768    console.error(`getSerialNumberForOsAccountLocalId exception: code is ${err.code}, message is ${err.message}`);
1769  }
1770  ```
1771
1772### isMultiOsAccountEnable<sup>(deprecated)</sup>
1773
1774isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
1775
1776判断是否支持多系统账号。使用callback异步回调。
1777
1778> **说明:**
1779>
1780> 从API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9)。
1781
1782**系统能力:** SystemCapability.Account.OsAccount
1783
1784**参数:**
1785
1786| 参数名   | 类型                         | 必填 | 说明                                                     |
1787| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
1788| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示支持多系统账号;返回false表示不支持。 |
1789
1790**示例:**
1791
1792  ```ts
1793  import { BusinessError } from '@kit.BasicServicesKit';
1794  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1795  accountManager.isMultiOsAccountEnable((err: BusinessError, isEnabled: boolean) => {
1796    if (err) {
1797      console.error(`isMultiOsAccountEnable failed, code is ${err.code}, message is ${err.message}`);
1798    } else {
1799    console.info('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
1800    }
1801  });
1802  ```
1803
1804### isMultiOsAccountEnable<sup>(deprecated)</sup>
1805
1806isMultiOsAccountEnable(): Promise&lt;boolean&gt;
1807
1808判断是否支持多系统账号。使用Promise异步回调。
1809
1810> **说明:**
1811>
1812> 从API version 7开始支持,从API version 9开始废弃。建议使用[checkMultiOsAccountEnabled](#checkmultiosaccountenabled9-1)。
1813
1814**系统能力:** SystemCapability.Account.OsAccount
1815
1816**返回值:**
1817
1818| 类型                   | 说明                                                       |
1819| :--------------------- | :--------------------------------------------------------- |
1820| Promise&lt;boolean&gt; | Promise对象。返回true表示支持多系统账号;返回false表示不支持。 |
1821
1822**示例:**
1823
1824  ```ts
1825  import { BusinessError } from '@kit.BasicServicesKit';
1826  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1827  accountManager.isMultiOsAccountEnable().then((isEnabled: boolean) => {
1828    console.info('isMultiOsAccountEnable successfully, isEnabled: ' + isEnabled);
1829  }).catch((err: BusinessError) => {
1830    console.error(`isMultiOsAccountEnable failed, code is ${err.code}, message is ${err.message}`);
1831  });
1832  ```
1833
1834### isOsAccountActived<sup>(deprecated)</sup>
1835
1836isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
1837
1838判断指定系统账号是否处于激活状态。使用callback异步回调。
1839
1840> **说明:**
1841>
1842> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1843
1844**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1845
1846**系统能力:** SystemCapability.Account.OsAccount
1847
1848**参数:**
1849
1850| 参数名   | 类型                         | 必填 | 说明                                                     |
1851| -------- | ---------------------------- | ---- | ------------------------------------------------------ |
1852| localId  | number                       | 是   | 系统账号ID。                                            |
1853| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示账号已激活;返回false表示账号未激活。 |
1854
1855**示例:** 判断ID为100的系统账号是否处于激活状态
1856
1857  ```ts
1858  import { BusinessError } from '@kit.BasicServicesKit';
1859  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1860  let localId: number = 100;
1861  accountManager.isOsAccountActived(localId, (err: BusinessError, isActived: boolean) => {
1862    if (err) {
1863      console.error(`isOsAccountActived failed, code is ${err.code}, message is ${err.message}`);
1864    } else {
1865      console.info('isOsAccountActived successfully, isActived:' + isActived);
1866    }
1867  });
1868  ```
1869
1870### isOsAccountActived<sup>(deprecated)</sup>
1871
1872isOsAccountActived(localId: number): Promise&lt;boolean&gt;
1873
1874判断指定系统账号是否处于激活状态。使用Promise异步回调。
1875
1876> **说明:**
1877>
1878> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1879
1880**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
1881
1882**系统能力:** SystemCapability.Account.OsAccount
1883
1884**参数:**
1885
1886| 参数名  | 类型   | 必填 | 说明                               |
1887| ------- | ------ | ---- | --------------------------------- |
1888| localId | number | 是   | 系统账号ID。 |
1889
1890**返回值:**
1891
1892| 类型                   | 说明                                                        |
1893| --------------------- | ----------------------------------------------------------- |
1894| Promise&lt;boolean&gt; | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 |
1895
1896**示例:** 判断ID为100的系统账号是否处于激活状态
1897
1898  ```ts
1899  import { BusinessError } from '@kit.BasicServicesKit';
1900  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1901  let localId: number = 100;
1902  accountManager.isOsAccountActived(localId).then((isActived: boolean) => {
1903    console.info('isOsAccountActived successfully, isActived: ' + isActived);
1904  }).catch((err: BusinessError) => {
1905    console.error(`isOsAccountActived failed, code is ${err.code}, message is ${err.message}`);
1906  });
1907  ```
1908
1909### isOsAccountConstraintEnable<sup>(deprecated)</sup>
1910
1911isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void
1912
1913判断指定系统账号是否具有指定约束。使用callback异步回调。
1914
1915> **说明:**
1916>
1917> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1918
1919**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
1920
1921**系统能力:** SystemCapability.Account.OsAccount
1922
1923**参数:**
1924
1925| 参数名     | 类型                         | 必填 | 说明                                                                |
1926| ---------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
1927| localId    | number                       | 是   | 系统账号ID。                                 |
1928| constraint | string                       | 是   | 指定的[约束](#系统账号约束列表)名称。                                |
1929| callback   | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
1930
1931**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
1932
1933  ```ts
1934  import { BusinessError } from '@kit.BasicServicesKit';
1935  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1936  let localId: number = 100;
1937  let constraint: string = 'constraint.wifi';
1938  accountManager.isOsAccountConstraintEnable(localId, constraint, (err: BusinessError, isEnabled: boolean) => {
1939    if (err) {
1940      console.error(`isOsAccountConstraintEnable failed, code is ${err.code}, message is ${err.message}`);
1941    } else {
1942      console.info('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
1943    }
1944  });
1945  ```
1946
1947### isOsAccountConstraintEnable<sup>(deprecated)</sup>
1948
1949isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boolean&gt;
1950
1951判断指定系统账号是否具有指定约束。使用Promise异步回调。
1952
1953> **说明:**
1954>
1955> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
1956
1957**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
1958
1959**系统能力:** SystemCapability.Account.OsAccount
1960
1961**参数:**
1962
1963| 参数名     | 类型   | 必填 | 说明                                 |
1964| ---------- | ------ | ---- | ---------------------------------- |
1965| localId    | number | 是   | 系统账号ID。  |
1966| constraint | string | 是   | 指定的[约束](#系统账号约束列表)名称。 |
1967
1968**返回值:**
1969
1970| 类型                   | 说明                                                                   |
1971| ---------------------- | --------------------------------------------------------------------- |
1972| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
1973
1974**示例:** 判断ID为100的系统账号是否有禁止使用Wi-Fi的约束
1975
1976  ```ts
1977  import { BusinessError } from '@kit.BasicServicesKit';
1978  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1979  let localId: number = 100;
1980  let constraint: string = 'constraint.wifi';
1981  accountManager.isOsAccountConstraintEnable(localId, constraint).then((isEnabled: boolean) => {
1982    console.info('isOsAccountConstraintEnable successfully, isEnabled: ' + isEnabled);
1983  }).catch((err: BusinessError) => {
1984    console.error(`isOsAccountConstraintEnable err: code is ${err.code}, message is ${err.message}`);
1985  });
1986  ```
1987
1988### isTestOsAccount<sup>(deprecated)</sup>
1989
1990isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
1991
1992检查当前系统账号是否为测试账号。使用callback异步回调。
1993
1994> **说明:**
1995>
1996> 从API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9)。
1997
1998**系统能力:** SystemCapability.Account.OsAccount
1999
2000**参数:**
2001
2002| 参数名   | 类型                         | 必填 | 说明                                                                   |
2003| -------- | ---------------------------- | ---- | --------------------------------------------------------------------- |
2004| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
2005
2006**示例:**
2007
2008  ```ts
2009  import { BusinessError } from '@kit.BasicServicesKit';
2010  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2011  accountManager.isTestOsAccount((err: BusinessError, isTestable: boolean) => {
2012    if (err) {
2013      console.error(`isTestOsAccount failed, code is ${err.code}, message is ${err.message}`);
2014    } else {
2015      console.info('isTestOsAccount successfully, isTestable: ' + isTestable);
2016    }
2017  });
2018  ```
2019
2020### isTestOsAccount<sup>(deprecated)</sup>
2021
2022isTestOsAccount(): Promise&lt;boolean&gt;
2023
2024检查当前系统账号是否为测试账号。使用Promise异步回调。
2025
2026> **说明:**
2027>
2028> 从API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountTestable](#checkosaccounttestable9-1)。
2029
2030**系统能力:** SystemCapability.Account.OsAccount
2031
2032**返回值:**
2033
2034| 类型                   | 说明                                                                      |
2035| ---------------------- | ------------------------------------------------------------------------ |
2036| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号为测试账号;返回false表示当前账号非测试账号。 |
2037
2038**示例:**
2039
2040  ```ts
2041  import { BusinessError } from '@kit.BasicServicesKit';
2042  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2043    accountManager.isTestOsAccount().then((isTestable: boolean) => {
2044      console.info('isTestOsAccount successfully, isTestable: ' + isTestable);
2045    }).catch((err: BusinessError) => {
2046      console.error(`isTestOsAccount failed, code is ${err.code}, message is ${err.message}`);
2047  });
2048  ```
2049
2050### isOsAccountVerified<sup>(deprecated)</sup>
2051
2052isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
2053
2054检查当前系统账号是否已验证。使用callback异步回调。
2055
2056> **说明:**
2057>
2058> 从API version 7开始支持,从API version 9开始废弃。建议使用[checkOsAccountVerified](#checkosaccountverifieddeprecated)。
2059
2060**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
2061
2062**系统能力:** SystemCapability.Account.OsAccount
2063
2064**参数:**
2065
2066| 参数名   | 类型                         | 必填 | 说明                                                            |
2067| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
2068| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
2069
2070**示例:**
2071
2072  ```ts
2073  import { BusinessError } from '@kit.BasicServicesKit';
2074  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2075  accountManager.isOsAccountVerified((err: BusinessError, isVerified: boolean) => {
2076    if (err) {
2077      console.error(`isOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
2078    } else {
2079      console.info('isOsAccountVerified successfully, isVerified: ' + isVerified);
2080    }
2081  });
2082  ```
2083
2084### isOsAccountVerified<sup>(deprecated)</sup>
2085
2086isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
2087
2088检查指定系统账号是否已验证。使用callback异步回调。
2089
2090> **说明:**
2091>
2092> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2093
2094**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
2095
2096**系统能力:** SystemCapability.Account.OsAccount
2097
2098**参数:**
2099
2100| 参数名   | 类型                         | 必填 | 说明                                                            |
2101| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
2102| localId  | number                       | 是   | 系统账号ID。                             |
2103| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
2104
2105**示例:**
2106
2107  ```ts
2108  import { BusinessError } from '@kit.BasicServicesKit';
2109  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2110  let localId: number = 100;
2111  accountManager.isOsAccountVerified(localId, (err: BusinessError, isVerified: boolean) => {
2112    if (err) {
2113      console.error(`isOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
2114    } else {
2115      console.info('isOsAccountVerified successfully, isVerified: ' + isVerified);
2116    }
2117  });
2118  ```
2119
2120### isOsAccountVerified<sup>(deprecated)</sup>
2121
2122isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
2123
2124检查指定系统账号是否已验证。使用Promise异步回调。
2125
2126> **说明:**
2127>
2128> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2129
2130**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限仅系统应用可申请。
2131
2132**系统能力:** SystemCapability.Account.OsAccount
2133
2134**参数:**
2135
2136| 参数名  | 类型   | 必填 | 说明                                                              |
2137| ------- | ------ | ---- | ---------------------------------------------------------------- |
2138| localId | number | 否   | 系统账号ID。不填则检查当前系统账号是否已验证,默认为-1。 |
2139
2140**返回值:**
2141
2142| 类型                   | 说明                                                               |
2143| ---------------------- | ----------------------------------------------------------------- |
2144| Promise&lt;boolean&gt; | Promise对象。返回true表示指定账号已验证;返回false表示指定账号未验证。 |
2145
2146**示例:**
2147
2148  ```ts
2149  import { BusinessError } from '@kit.BasicServicesKit';
2150  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2151  accountManager.isOsAccountVerified().then((isVerified: boolean) => {
2152    console.info('isOsAccountVerified successfully, isVerified: ' + isVerified);
2153  }).catch((err: BusinessError) => {
2154    console.error(`isOsAccountVerified failed, code is ${err.code}, message is ${err.message}`);
2155  });
2156  ```
2157
2158### getCreatedOsAccountsCount<sup>(deprecated)</sup>
2159
2160getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
2161
2162获取已创建的系统账号数量。使用callback异步回调。
2163
2164> **说明:**
2165>
2166> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9)。
2167
2168**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2169
2170**系统能力:** SystemCapability.Account.OsAccount
2171
2172**参数:**
2173
2174| 参数名   | 类型                        | 必填 | 说明                                                                         |
2175| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
2176| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为已创建的系统账号的数量;否则为错误对象。 |
2177
2178**示例:**
2179
2180  ```ts
2181  import { BusinessError } from '@kit.BasicServicesKit';
2182  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2183  accountManager.getCreatedOsAccountsCount((err: BusinessError, count: number)=>{
2184    if (err) {
2185      console.error(`getCreatedOsAccountsCount failed, code is ${err.code}, message is ${err.message}`);
2186    } else {
2187      console.info('getCreatedOsAccountsCount successfully, count: ' + count);
2188    }
2189  });
2190  ```
2191
2192### getCreatedOsAccountsCount<sup>(deprecated)</sup>
2193
2194getCreatedOsAccountsCount(): Promise&lt;number&gt;
2195
2196获取已创建的系统账号数量。使用Promise异步回调。
2197
2198> **说明:**
2199>
2200> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountCount](#getosaccountcount9-1)。
2201
2202**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2203
2204**系统能力:** SystemCapability.Account.OsAccount
2205
2206**返回值:**
2207
2208| 类型                  | 说明                                    |
2209| --------------------- | -------------------------------------- |
2210| Promise&lt;number&gt; | Promise对象,返回已创建的系统账号的数量。 |
2211
2212**示例:**
2213
2214  ```ts
2215  import { BusinessError } from '@kit.BasicServicesKit';
2216  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2217  accountManager.getCreatedOsAccountsCount().then((count: number) => {
2218    console.info('getCreatedOsAccountsCount successfully, count: ' + count);
2219  }).catch((err: BusinessError) => {
2220    console.error(`getCreatedOsAccountsCount failed, code is ${err.code}, message is ${err.message}`);
2221  });
2222  ```
2223
2224### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup>
2225
2226getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
2227
2228获取当前进程所属的系统账号ID。使用callback异步回调。
2229
2230> **说明:**
2231>
2232> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9)。
2233
2234**系统能力:** SystemCapability.Account.OsAccount
2235
2236**参数:**
2237
2238| 参数名   | 类型                        | 必填 | 说明                                                                           |
2239| -------- | --------------------------- | ---- | ---------------------------------------------------------------------------- |
2240| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为当前进程所属的系统账号ID;否则为错误对象。 |
2241
2242**示例:**
2243
2244  ```ts
2245  import { BusinessError } from '@kit.BasicServicesKit';
2246  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2247  accountManager.getOsAccountLocalIdFromProcess((err: BusinessError, localId: number) => {
2248    if (err) {
2249      console.error(`getOsAccountLocalIdFromProcess failed, code is ${err.code}, message is ${err.message}`);
2250    } else {
2251      console.info('getOsAccountLocalIdFromProcess id:: ' + localId);
2252    }
2253  });
2254  ```
2255
2256### getOsAccountLocalIdFromProcess<sup>(deprecated)</sup>
2257
2258getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
2259
2260获取当前进程所属的系统账号ID。使用Promise异步回调。
2261
2262> **说明:**
2263>
2264> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalId](#getosaccountlocalid9-1)。
2265
2266**系统能力:** SystemCapability.Account.OsAccount
2267
2268**返回值:**
2269
2270| 类型                  | 说明                                      |
2271| :-------------------- | :--------------------------------------- |
2272| Promise&lt;number&gt; | Promise对象,返回当前进程所属的系统账号ID。 |
2273
2274**示例:**
2275
2276  ```ts
2277  import { BusinessError } from '@kit.BasicServicesKit';
2278  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2279  accountManager.getOsAccountLocalIdFromProcess().then((localId: number) => {
2280    console.info('getOsAccountLocalIdFromProcess successfully, localId: ' + localId);
2281  }).catch((err: BusinessError) => {
2282    console.error(`getOsAccountLocalIdFromProcess failed, code is ${err.code}, message is ${err.message}`);
2283  });
2284  ```
2285
2286### getOsAccountLocalIdFromUid<sup>(deprecated)</sup>
2287
2288getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
2289
2290根据uid查询对应的系统账号ID。使用callback异步回调。
2291
2292> **说明:**
2293>
2294> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9)。
2295
2296**系统能力:** SystemCapability.Account.OsAccount
2297
2298**参数:**
2299
2300| 参数名   | 类型                        | 必填 | 说明                                                                    |
2301| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
2302| uid      | number                      | 是   | 进程uid。                                                              |
2303| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为对应的系统账号ID;否则为错误对象。 |
2304
2305**示例:** 查询值为12345678的uid所属的系统账号ID
2306
2307  ```ts
2308  import { BusinessError } from '@kit.BasicServicesKit';
2309  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2310  let uid: number = 12345678;
2311  accountManager.getOsAccountLocalIdFromUid(uid, (err: BusinessError, localId: number) => {
2312    if (err) {
2313      console.error(`getOsAccountLocalIdFromUid failed, code is ${err.code}, message is ${err.message}`);
2314    } else {
2315      console.info('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
2316    }
2317  });
2318  ```
2319
2320### getOsAccountLocalIdFromUid<sup>(deprecated)</sup>
2321
2322getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
2323
2324根据uid查询对应的系统账号ID。使用Promise异步回调。
2325
2326> **说明:**
2327>
2328> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForUid](#getosaccountlocalidforuid9-1)。
2329
2330**系统能力:** SystemCapability.Account.OsAccount
2331
2332**参数:**
2333
2334| 参数名 | 类型   | 必填 | 说明      |
2335| ------ | ------ | ---- | --------- |
2336| uid    | number | 是   | 进程uid。 |
2337
2338**返回值:**
2339
2340| 类型                  | 说明                                  |
2341| :-------------------- | :----------------------------------- |
2342| Promise&lt;number&gt; | Promise对象,返回uid对应的系统账号ID。 |
2343
2344**示例:** 查询值为12345678的uid所属的系统账号ID
2345
2346  ```ts
2347  import { BusinessError } from '@kit.BasicServicesKit';
2348  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2349  let uid: number = 12345678;
2350  accountManager.getOsAccountLocalIdFromUid(uid).then((localId: number) => {
2351    console.info('getOsAccountLocalIdFromUid successfully, localId: ' + localId);
2352  }).catch((err: BusinessError) => {
2353    console.error(`getOsAccountLocalIdFromUid failed, code is ${err.code}, message is ${err.message}`);
2354  });
2355  ```
2356
2357### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup>
2358
2359getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
2360
2361根据域账号信息,获取与其关联的系统账号的账号ID。使用callback异步回调。
2362
2363> **说明:**
2364>
2365> 从API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9)。
2366
2367**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2368
2369**系统能力:** SystemCapability.Account.OsAccount
2370
2371**参数:**
2372
2373| 参数名     | 类型                                    | 必填 | 说明                                                                         |
2374| ---------- | --------------------------------------- | ---- | --------------------------------------------------------------------------- |
2375| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。                                                                |
2376| callback   | AsyncCallback&lt;number&gt;             | 是   | 回调函数,如果获取成功,err为null,data为域账号关联的系统账号ID;否则为错误对象。 |
2377
2378**示例:**
2379
2380  ```ts
2381  import { BusinessError } from '@kit.BasicServicesKit';
2382  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
2383  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2384  accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err: BusinessError, localId: number) => {
2385    if (err) {
2386      console.error(`getOsAccountLocalIdFromDomain failed, code is ${err.code}, message is ${err.message}`);
2387    } else {
2388      console.info('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
2389    }
2390  });
2391  ```
2392
2393### getOsAccountLocalIdFromDomain<sup>(deprecated)</sup>
2394
2395getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
2396
2397根据域账号信息,获取与其关联的系统账号的账号ID。使用Promise异步回调。
2398
2399> **说明:**
2400>
2401> 从API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForDomain](#getosaccountlocalidfordomain9-1)。
2402
2403**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2404
2405**系统能力:** SystemCapability.Account.OsAccount
2406
2407**参数:**
2408
2409| 参数名     | 类型                                    | 必填 | 说明         |
2410| ---------- | --------------------------------------- | ---- | ------------ |
2411| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。 |
2412
2413**返回值:**
2414
2415| 类型                  | 说明                                    |
2416| :-------------------- | :------------------------------------- |
2417| Promise&lt;number&gt; | Promise对象,返回域账号关联的系统账号ID。 |
2418
2419**示例:**
2420
2421  ```ts
2422  import { BusinessError } from '@kit.BasicServicesKit';
2423  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2424  let domainInfo: osAccount.DomainAccountInfo = {domain: 'testDomain', accountName: 'testAccountName'};
2425  accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((localId: number) => {
2426    console.info('getOsAccountLocalIdFromDomain successfully, localId: ' + localId);
2427  }).catch((err: BusinessError) => {
2428    console.error(`getOsAccountLocalIdFromDomain failed, code is ${err.code}, message is ${err.message}`);
2429  });
2430  ```
2431
2432### getOsAccountAllConstraints<sup>(deprecated)</sup>
2433
2434getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
2435
2436获取指定系统账号的全部约束。使用callback异步回调。
2437
2438> **说明:**
2439>
2440> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2441
2442**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2443
2444**系统能力:** SystemCapability.Account.OsAccount
2445
2446**参数:**
2447
2448| 参数名   | 类型                                     | 必填 | 说明                                                                                             |
2449| -------- | ---------------------------------------- | ---- | ---------------------------------------------------------------------------------------------- |
2450| localId  | number                                   | 是   | 系统账号ID。                                                                                    |
2451| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是   | 回调函数。如果获取成功,err为null,data为指定系统账号的全部[约束](#系统账号约束列表);否则为错误对象。 |
2452
2453**示例:** 获取ID为100的系统账号的全部约束
2454
2455  ```ts
2456  import { BusinessError } from '@kit.BasicServicesKit';
2457  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2458  let localId: number = 100;
2459  accountManager.getOsAccountAllConstraints(localId, (err: BusinessError, constraints: string[])=>{
2460    if (err) {
2461      console.error(`getOsAccountAllConstraints code is ${err.code}, message is ${err.message}`);
2462    } else {
2463      console.info('getOsAccountAllConstraints:' + JSON.stringify(constraints));
2464    }
2465  });
2466  ```
2467
2468### getOsAccountAllConstraints<sup>(deprecated)</sup>
2469
2470getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
2471
2472获取指定系统账号的全部约束。使用Promise异步回调。
2473
2474> **说明:**
2475>
2476> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2477
2478**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2479
2480**系统能力:** SystemCapability.Account.OsAccount
2481
2482**参数:**
2483
2484| 参数名  | 类型   | 必填 | 说明         |
2485| ------- | ------ | ---- | ------------ |
2486| localId | number | 是   | 系统账号ID。 |
2487
2488**返回值:**
2489
2490| 类型                               | 说明                                                         |
2491| :--------------------------------- | :----------------------------------------------------------- |
2492| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统账号的全部[约束](#系统账号约束列表)。 |
2493
2494**示例:** 获取ID为100的系统账号的全部约束
2495
2496  ```ts
2497  import { BusinessError } from '@kit.BasicServicesKit';
2498  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2499  let localId: number = 100;
2500  accountManager.getOsAccountAllConstraints(localId).then((constraints: string[]) => {
2501    console.info('getOsAccountAllConstraints, constraints: ' + constraints);
2502  }).catch((err: BusinessError) => {
2503    console.error(`getOsAccountAllConstraints err: code is ${err.code}, message is ${err.message}`);
2504  });
2505  ```
2506
2507### queryActivatedOsAccountIds<sup>(deprecated)</sup>
2508
2509queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
2510
2511查询当前处于激活状态的系统账号的ID列表。使用callback异步回调。
2512
2513> **说明:**
2514>
2515> 从API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9)。
2516
2517**系统能力:** SystemCapability.Account.OsAccount
2518
2519**参数:**
2520
2521| 参数名   | 类型                                     | 必填 | 说明                                                   |
2522| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
2523| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前处于激活状态的系统账号的ID列表;否则为错误对象。 |
2524
2525**示例:**
2526
2527  ```ts
2528  import { BusinessError } from '@kit.BasicServicesKit';
2529  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2530  accountManager.queryActivatedOsAccountIds((err: BusinessError, idArray: number[])=>{
2531      if (err) {
2532        console.error(`queryActivatedOsAccountIds code is ${err.code}, message is ${err.message}`);
2533      } else {
2534        console.info('queryActivatedOsAccountIds idArray length:' + idArray.length);
2535        for(let i=0;i<idArray.length;i++) {
2536          console.info('activated os account id: ' + idArray[i]);
2537        }
2538      }
2539  });
2540  ```
2541
2542### queryActivatedOsAccountIds<sup>(deprecated)</sup>
2543
2544queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
2545
2546> **说明:**
2547>
2548> 从API version 8开始支持,从API version 9开始废弃。建议使用[getActivatedOsAccountLocalIds](#getactivatedosaccountlocalids9-1)。
2549
2550查询当前处于激活状态的系统账号的ID列表。使用Promise异步回调。
2551
2552**系统能力:** SystemCapability.Account.OsAccount
2553
2554**返回值:**
2555
2556| 类型                               | 说明                                               |
2557| ---------------------------------- | ------------------------------------------------- |
2558| Promise&lt;Array&lt;number&gt;&gt; | Promise对象,返回当前处于激活状态的系统账号的ID列表。 |
2559
2560**示例:**
2561
2562  ```ts
2563  import { BusinessError } from '@kit.BasicServicesKit';
2564  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2565  accountManager.queryActivatedOsAccountIds().then((idArray: number[]) => {
2566    console.info('queryActivatedOsAccountIds, idArray: ' + idArray);
2567  }).catch((err: BusinessError) => {
2568    console.error(`queryActivatedOsAccountIds err: code is ${err.code}, message is ${err.message}`);
2569  });
2570  ```
2571
2572### queryCurrentOsAccount<sup>(deprecated)</sup>
2573
2574queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
2575
2576查询当前进程所属的系统账号的信息。使用callback异步回调。
2577
2578> **说明:**
2579>
2580> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2581
2582**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2583
2584**系统能力:** SystemCapability.Account.OsAccount
2585
2586**参数:**
2587
2588| 参数名   | 类型                                                 | 必填 | 说明                                           |
2589| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
2590| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号信息;否则为错误对象。 |
2591
2592**示例:**
2593
2594  ```ts
2595  import { BusinessError } from '@kit.BasicServicesKit';
2596  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2597  accountManager.queryCurrentOsAccount((err: BusinessError, curAccountInfo: osAccount.OsAccountInfo)=>{
2598    if (err) {
2599      console.error(`queryCurrentOsAccount code is ${err.code}, message is ${err.message}`);
2600    } else {
2601      console.info('queryCurrentOsAccount curAccountInfo:' + JSON.stringify(curAccountInfo));
2602    }
2603  });
2604  ```
2605
2606### queryCurrentOsAccount<sup>(deprecated)</sup>
2607
2608queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
2609
2610查询当前进程所属的系统账号的信息。使用Promise异步回调。
2611
2612> **说明:**
2613>
2614> 从API version 7开始支持,从API version 9开始废弃。替代方法仅向系统应用开放。
2615
2616**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS,该权限仅系统应用可申请。
2617
2618**系统能力:** SystemCapability.Account.OsAccount
2619
2620**返回值:**
2621
2622| 类型                                           | 说明                                       |
2623| ---------------------------------------------- | ------------------------------------------ |
2624| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统账号信息。 |
2625
2626**示例:**
2627
2628  ```ts
2629  import { BusinessError } from '@kit.BasicServicesKit';
2630  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2631  accountManager.queryCurrentOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
2632    console.info('queryCurrentOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
2633  }).catch((err: BusinessError) => {
2634    console.error(`queryCurrentOsAccount err: code is ${err.code}, message is ${err.message}`);
2635  });
2636  ```
2637
2638### getOsAccountTypeFromProcess<sup>(deprecated)</sup>
2639
2640getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
2641
2642查询当前进程所属的系统账号的账号类型。使用callback异步回调。
2643
2644> **说明:**
2645>
2646> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9)。
2647
2648**系统能力:** SystemCapability.Account.OsAccount
2649
2650**参数:**
2651
2652| 参数名   | 类型                                                 | 必填 | 说明                                                 |
2653| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
2654| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是   | 回调函数。如果查询成功,err为null,data为当前进程所属的系统账号的账号类型;否则为错误对象。 |
2655
2656**示例:**
2657
2658  ```ts
2659  import { BusinessError } from '@kit.BasicServicesKit';
2660  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2661  accountManager.getOsAccountTypeFromProcess((err: BusinessError, accountType: osAccount.OsAccountType) => {
2662    if (err) {
2663      console.error(`getOsAccountTypeFromProcess err: code is ${err.code}, message is ${err.message}`);
2664    } else {
2665      console.info('getOsAccountTypeFromProcess accountType: ' + accountType);
2666    }
2667  });
2668  ```
2669
2670### getOsAccountTypeFromProcess<sup>(deprecated)</sup>
2671
2672getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
2673
2674查询当前进程所属的系统账号的账号类型。使用Promise异步回调。
2675
2676> **说明:**
2677>
2678> 从API version 7开始支持,从API version 9开始废弃。建议使用[getOsAccountType](#getosaccounttype9-1)。
2679
2680**系统能力:** SystemCapability.Account.OsAccount
2681
2682**返回值:**
2683
2684| 类型                                           | 说明                                            |
2685| ---------------------------------------------- | ----------------------------------------------- |
2686| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise对象,返回当前进程所属的系统账号的账号类型。 |
2687
2688**示例:**
2689
2690  ```ts
2691  import { BusinessError } from '@kit.BasicServicesKit';
2692  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2693  accountManager.getOsAccountTypeFromProcess().then((accountType: osAccount.OsAccountType) => {
2694    console.info('getOsAccountTypeFromProcess, accountType: ' + accountType);
2695  }).catch((err: BusinessError) => {
2696    console.error(`getOsAccountTypeFromProcess err: code is ${err.code}, message is ${err.message}`);
2697  });
2698  ```
2699
2700### getDistributedVirtualDeviceId<sup>(deprecated)</sup>
2701
2702getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
2703
2704获取分布式虚拟设备ID。使用callback异步回调。
2705
2706> **说明:**
2707>
2708> 从API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9)。
2709
2710**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或 ohos.permission.DISTRIBUTED_DATASYNC
2711
2712**系统能力:** SystemCapability.Account.OsAccount
2713
2714**参数:**
2715
2716| 参数名   | 类型                        | 必填 | 说明                                                                    |
2717| -------- | --------------------------- | ---- | --------------------------------------------------------------------- |
2718| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为分布式虚拟设备ID;否则为错误对象。 |
2719
2720**示例:**
2721
2722  ```ts
2723  import { BusinessError } from '@kit.BasicServicesKit';
2724  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2725  accountManager.getDistributedVirtualDeviceId((err: BusinessError, virtualID: string) => {
2726    if (err) {
2727      console.error(`getDistributedVirtualDeviceId err: code is ${err.code}, message is ${err.message}`);
2728    } else {
2729      console.info('getDistributedVirtualDeviceId virtualID: ' + virtualID);
2730    }
2731  });
2732  ```
2733
2734### getDistributedVirtualDeviceId<sup>(deprecated)</sup>
2735
2736getDistributedVirtualDeviceId(): Promise&lt;string&gt;
2737
2738获取分布式虚拟设备ID。使用Promise异步回调。
2739
2740> **说明:**
2741>
2742> 从API version 7开始支持,从API version 9开始废弃。建议使用[queryDistributedVirtualDeviceId](#querydistributedvirtualdeviceid9-1)。
2743
2744**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS(仅系统应用可申请)或ohos.permission.DISTRIBUTED_DATASYNC
2745
2746**系统能力:** SystemCapability.Account.OsAccount
2747
2748**返回值:**
2749
2750| 类型                  | 说明                              |
2751| --------------------- | --------------------------------- |
2752| Promise&lt;string&gt; | Promise对象,返回分布式虚拟设备ID。 |
2753
2754**示例:**
2755
2756  ```ts
2757  import { BusinessError } from '@kit.BasicServicesKit';
2758  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2759  accountManager.getDistributedVirtualDeviceId().then((virtualID: string) => {
2760    console.info('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
2761  }).catch((err: BusinessError) => {
2762    console.error(`getDistributedVirtualDeviceId err: code is ${err.code}, message is ${err.message}`);
2763  });
2764  ```
2765
2766### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup>
2767
2768getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
2769
2770通过SN码查询与其关联的系统账号的账号ID。使用callback异步回调。
2771
2772> **说明:**
2773>
2774> 从API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9)。
2775
2776**系统能力:** SystemCapability.Account.OsAccount
2777
2778**参数:**
2779
2780| 参数名       | 类型                        | 必填 | 说明                                                                               |
2781| ------------ | --------------------------- | ---- | -------------------------------------------------------------------------------- |
2782| serialNumber | number                      | 是   | 账号SN码。                                                                        |
2783| callback     | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为与SN码关联的系统账号的账号ID;否则为错误对象。 |
2784
2785**示例:** 查询与SN码12345关联的系统账号的ID
2786
2787  ```ts
2788  import { BusinessError } from '@kit.BasicServicesKit';
2789  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2790  let serialNumber: number = 12345;
2791  accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err: BusinessError, localId: number)=>{
2792    if (err) {
2793      console.error(`get localId code is ${err.code}, message is ${err.message}`);
2794    } else {
2795      console.info('get localId:' + localId + ' by serialNumber: ' + serialNumber);
2796    }
2797  });
2798  ```
2799
2800### getOsAccountLocalIdBySerialNumber<sup>(deprecated)</sup>
2801
2802getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
2803
2804通过SN码查询与其关联的系统账号的账号ID。使用Promise异步回调。
2805
2806> **说明:**
2807>
2808> 从API version 8开始支持,从API version 9开始废弃。建议使用[getOsAccountLocalIdForSerialNumber](#getosaccountlocalidforserialnumber9-1)。
2809
2810**系统能力:** SystemCapability.Account.OsAccount
2811
2812**参数:**
2813
2814| 参数名       | 类型   | 必填 | 说明       |
2815| ------------ | ------ | ---- | ---------- |
2816| serialNumber | number | 是   | 账号SN码。 |
2817
2818**返回值:**
2819
2820| 类型                  | 说明                                                         |
2821| --------------------- | -------------------------------------------- |
2822| Promise&lt;number&gt; | Promise对象,返回与SN码关联的系统账号的账号ID。 |
2823
2824**示例:** 查询与SN码12345关联的系统账号的ID
2825
2826  ```ts
2827  import { BusinessError } from '@kit.BasicServicesKit';
2828  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2829  let serialNumber: number = 12345;
2830  accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId: number) => {
2831    console.info('getOsAccountLocalIdBySerialNumber localId: ' + localId);
2832  }).catch((err: BusinessError) => {
2833    console.error(`getOsAccountLocalIdBySerialNumber err: code is ${err.code}, message is ${err.message}`);
2834  });
2835  ```
2836
2837### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup>
2838
2839getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
2840
2841通过系统账号ID获取与该系统账号关联的SN码。使用callback异步回调。
2842
2843> **说明:**
2844>
2845> 从API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9)。
2846
2847**系统能力:** SystemCapability.Account.OsAccount
2848
2849**参数:**
2850
2851| 参数名   | 类型                        | 必填 | 说明                                                                         |
2852| -------- | --------------------------- | ---- | --------------------------------------------------------------------------- |
2853| localId  | number                      | 是   | 系统账号ID。                                                                 |
2854| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果获取成功,err为null,data为与该系统账号关联的SN码;否则为错误对象。 |
2855
2856**示例:** 获取ID为100的系统账号关联的SN码
2857
2858  ```ts
2859  import { BusinessError } from '@kit.BasicServicesKit';
2860  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2861  let localId: number = 100;
2862  accountManager.getSerialNumberByOsAccountLocalId(localId, (err: BusinessError, serialNumber: number)=>{
2863    if (err) {
2864      console.error(`get serialNumber code is ${err.code}, message is ${err.message}`);
2865    } else {
2866      console.info('get serialNumber:' + serialNumber + ' by localId: ' + localId);
2867    }
2868  });
2869  ```
2870
2871### getSerialNumberByOsAccountLocalId<sup>(deprecated)</sup>
2872
2873getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
2874
2875通过系统账号ID获取与该系统账号关联的SN码。使用Promise异步回调。
2876
2877> **说明:**
2878>
2879> 从API version 8开始支持,从API version 9开始废弃。建议使用[getSerialNumberForOsAccountLocalId](#getserialnumberforosaccountlocalid9-1)。
2880
2881**系统能力:** SystemCapability.Account.OsAccount
2882
2883**参数:**
2884
2885| 参数名  | 类型   | 必填 | 说明          |
2886| ------- | ------ | ---- | ----------- |
2887| localId | number | 是   | 系统账号ID。 |
2888
2889**返回值:**
2890
2891| 类型                  | 说明                                    |
2892| --------------------- | -------------------------------------- |
2893| Promise&lt;number&gt; | Promise对象,返回与该系统账号关联的SN码。 |
2894
2895**示例:** 获取ID为100的系统账号关联的SN码
2896
2897  ```ts
2898  import { BusinessError } from '@kit.BasicServicesKit';
2899  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2900  let localId: number = 100;
2901  accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber: number) => {
2902    console.info('getSerialNumberByOsAccountLocalId serialNumber: ' + serialNumber);
2903  }).catch((err: BusinessError) => {
2904    console.error(`getSerialNumberByOsAccountLocalId err: code is ${err.code}, message is ${err.message}`);
2905  });
2906  ```
2907
2908### getOsAccountName<sup>12+</sup>
2909
2910getOsAccountName(): Promise&lt;string&gt;
2911
2912查询调用方所属系统账号的名称。使用Promise异步回调。
2913
2914**系统能力:** SystemCapability.Account.OsAccount
2915
2916**返回值:**
2917
2918| 类型                      | 说明                     |
2919| :------------------------ | ----------------------- |
2920| Promise&lt;string&gt; | Promise对象,返回调用方所属系统账号的名称。 |
2921
2922**错误码:**
2923
2924以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
2925
2926| 错误码ID | 错误信息                     |
2927| -------- | --------------------------- |
2928| 12300001 | The system service works abnormally. |
2929
2930**示例:**
2931  ```ts
2932  import { BusinessError } from '@kit.BasicServicesKit';
2933  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2934  try {
2935    accountManager.getOsAccountName().then((name: string) => {
2936      console.info('getOsAccountName, name: ' + name);
2937    }).catch((err: BusinessError) => {
2938      console.error('getOsAccountName err: ' + err);
2939    });
2940  } catch (e) {
2941    const err = e as BusinessError;
2942    console.error(`getOsAccountName exception: code is ${err.code}, message is ${err.message}`);
2943  }
2944  ```
2945
2946### getForegroundOsAccountLocalId<sup>15+</sup>
2947
2948getForegroundOsAccountLocalId(): Promise&lt;number&gt;;
2949
2950获取前台系统账号的ID。
2951
2952**系统能力:** SystemCapability.Account.OsAccount
2953
2954**返回值:**
2955
2956| 类型                   | 说明                                                               |
2957| ---------------------- | ----------------------------------------------------------------- |
2958| Promise&lt;number&gt; | Promise对象。返回前台系统账号的ID。 |
2959
2960**错误码:**
2961
2962以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)。
2963
2964| 错误码ID | 错误信息       |
2965| -------- | ------------- |
2966| 12300001 | The system service works abnormally. |
2967
2968**示例:**
2969
2970  ```ts
2971  import { BusinessError } from '@kit.BasicServicesKit';
2972  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2973  try {
2974    accountManager.getForegroundOsAccountLocalId().then((localId: number) => {
2975      console.info('getForegroundOsAccountLocalId, localId: ' + localId);
2976    }).catch((err: BusinessError) => {
2977      console.error(`getForegroundOsAccountLocalId err: code is ${err.code}, message is ${err.message}`);
2978    });
2979  } catch (e) {
2980    const err = e as BusinessError;
2981    console.error(`getForegroundOsAccountLocalId exception: code is ${err.code}, message is ${err.message}`);
2982  }
2983  ```
2984
2985### getOsAccountDomainInfo<sup>15+</sup>
2986
2987getOsAccountDomainInfo(localId: number): Promise&lt;DomainAccountInfo&gt;;
2988
2989获取指定系统账号关联的域账号信息。
2990
2991**需要权限:** ohos.permission.GET_DOMAIN_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS,以上权限允许系统应用和企业应用进行申请。
2992
2993**系统能力:** SystemCapability.Account.OsAccount
2994
2995**参数:**
2996
2997| 参数名  | 类型   | 必填 | 说明          |
2998| ------- | ------ | ---- | ----------- |
2999| localId | number | 是   | 系统账号ID。 |
3000
3001**返回值:**
3002
3003| 类型                   | 说明                                                               |
3004| ---------------------- | ----------------------------------------------------------------- |
3005| Promise&lt;[DomainAccountInfo](#domainaccountinfo8)&gt; | Promise对象。返回与指定系统账号关联的域账号信息。 |
3006
3007**错误码:**
3008
3009以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3010
3011| 错误码ID | 错误信息       |
3012| -------- | ------------- |
3013| 201 | Permission denied. |
3014| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3015| 12300001 | The system service works abnormally. |
3016| 12300003 | OS account not found. |
3017
3018**示例:**
3019
3020  ```ts
3021  import { BusinessError } from '@kit.BasicServicesKit';
3022  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
3023  let localId: number = 100;
3024  accountManager.getOsAccountDomainInfo(localId).then((domainAccountInfo: osAccount.DomainAccountInfo) => {
3025    if (domainAccountInfo === null) {
3026      console.info('The target OS account is not a domain account.')
3027    } else {
3028      console.info('getOsAccountDomainInfo domain: ' + domainAccountInfo.domain);
3029      console.info('getOsAccountDomainInfo accountName: ' + domainAccountInfo.accountName);
3030    }
3031  }).catch((err: BusinessError) => {
3032    console.error(`getOsAccountDomainInfo err: code is ${err.code}, message is ${err.message}`);
3033  })
3034  ```
3035
3036## DomainAccountManager<sup>18+</sup>
3037
3038域账号管理类。
3039
3040### updateAccountInfo<sup>18+</sup>
3041
3042updateAccountInfo(oldAccountInfo: DomainAccountInfo, newAccountInfo: DomainAccountInfo): Promise&lt;void&gt;
3043
3044修改指定域账号信息。使用Promise异步回调。
3045
3046**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.MANAGE_DOMAIN_ACCOUNTS
3047
3048**系统能力:** SystemCapability.Account.OsAccount
3049
3050**参数:**
3051
3052| 参数名      | 类型                                    | 必填 | 说明             |
3053| ---------- | --------------------------------------- | ---- | --------------- |
3054| oldAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 表示旧域账号信息。|
3055| newAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 表示新域账号信息。|
3056
3057**返回值:**
3058
3059| 类型                      | 说明                     |
3060| :------------------------ | ----------------------- |
3061| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
3062
3063**错误码:**
3064
3065以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3066
3067| 错误码ID | 错误信息                     |
3068| -------- | --------------------------- |
3069| 201 | Permission denied.|
3070| 801 | Capability not supported.|
3071| 12300001 | The system service works abnormally. |
3072| 12300002 | The new account info is invalid. |
3073| 12300003 | The old account not found. |
3074| 12300004 | The new account already exists. |
3075
3076**示例:**
3077  ```ts
3078  import { BusinessError } from '@kit.BasicServicesKit';
3079  let oldDomainInfo: osAccount.DomainAccountInfo =
3080    {domain: 'testDomain', accountName: 'oldtestAccountName'};
3081  let newDomainInfo: osAccount.DomainAccountInfo =
3082    {domain: 'testDomain', accountName: 'newtestAccountName'};
3083  try {
3084    osAccount.DomainAccountManager.updateAccountInfo(oldDomainInfo, newDomainInfo).then(() => {
3085      console.info('updateAccountInfo, success');
3086    }).catch((err: BusinessError) => {
3087      console.error('updateAccountInfo err: ' + err);
3088    });
3089  } catch (e) {
3090    const err = e as BusinessError;
3091    console.error(`updateAccountInfo exception: code is ${err.code}, message is ${err.message}`);
3092  }
3093  ```
3094
3095## OsAccountInfo
3096
3097表示系统账号信息。
3098
3099**系统能力:** SystemCapability.Account.OsAccount
3100
3101| 名称                         | 类型                                                         | 只读  | 可选  | 说明                              |
3102| ------------------------------ | ------------------------------------------------------------ | ---- | ---- | --------------------------------- |
3103| localId                        | number                                                       | 否 | 否  | 系统账号ID。                      |
3104| localName                      | string                                                       | 否 | 否  | 系统账号名称。                    |
3105| type                           | [OsAccountType](#osaccounttype)                              | 否 | 否  | 系统账号类型。                      |
3106| constraints                    | Array&lt;string&gt;                                          | 否 | 否  | 系统账号[约束](#系统账号约束列表),默认为空。|
3107| isVerified<sup>(deprecated)</sup> | boolean                                                   | 否 | 否  | 账号是否验证。true表示指定账号已验证;false表示指定账号未验证。<br>**说明**:从API version 7开始支持,从API version 11开始废弃,建议使用isUnlocked。           |
3108| isUnlocked<sup>11+</sup>      | boolean                                                       | 否 | 否  | 账号是否已解锁(EL2级别目录是否解密)。true表示指定账号已解锁;false表示指定账号未解锁。                      |
3109| photo<sup>8+</sup>             | string                                                       | 否 | 否  | 系统账号头像,默认为空。                      |
3110| createTime<sup>8+</sup>        | number                                                       | 否 | 否  | 系统账号创建时间。                  |
3111| lastLoginTime<sup>8+</sup>     | number                                                       | 否 | 否  | 系统账号最后一次登录时间,默认为空。          |
3112| serialNumber<sup>8+</sup>      | number                                                       | 否 | 否  | 系统账号SN码。                      |
3113| isActived<sup>(deprecated)</sup>         | boolean                                            | 否 | 否  | 系统账号激活状态。true表示指定账号处于激活状态;false表示指定账号处于未激活状态。<br>**说明**:从API version 7开始支持,从API version 11开始废弃,建议使用isActivated。                  |
3114| isActivated<sup>11+</sup>         | boolean                                                   | 否 | 否  | 系统账号是否激活。true表示指定账号已激活;false表示指定账号未激活。                  |
3115| isCreateCompleted<sup>8+</sup> | boolean                                                      | 否 | 否  | 系统账号创建是否完整。true表示指定账号已创建完整;false表示指定账号未创建完整。              |
3116| distributedInfo                | [distributedAccount.DistributedInfo](js-apis-distributed-account.md#distributedinfo) | 否 | 否  | 分布式账号信息,默认为空。                    |
3117| domainInfo<sup>8+</sup>        | [DomainAccountInfo](#domainaccountinfo8)                      | 否 | 否  | 域账号信息,默认为空。                        |
3118
3119## DomainAccountInfo<sup>8+</sup>
3120
3121表示域账号信息。
3122
3123**系统能力:** SystemCapability.Account.OsAccount
3124
3125| 名称      | 类型   | 只读  | 可选 | 说明       |
3126| ----------- | ------ | ---- | ---- | ---------- |
3127| domain      | string | 否 | 否  | 域名。     |
3128| accountName | string | 否 | 否  | 域账号名。 |
3129| serverConfigId<sup>18+</sup> | string | 否 | 是  | 域账号配置ID,默认为空字符串。 |
3130
3131## DomainServerConfig<sup>18+</sup>
3132
3133域服务器配置。
3134
3135**系统能力:** SystemCapability.Account.OsAccount
3136
3137| 名称      | 类型   | 只读  | 可选 | 说明       |
3138| ----------- | ------ | ---- | ---- | ---------- |
3139| parameters | Record<string, Object> | 否 | 否  | 服务器配置参数。 |
3140| id | string | 否 | 否  | 服务器配置标识。|
3141| domain | string | 否 | 否  | 服务器所属的域。 |
3142
3143## DomainServerConfigManager<sup>18+</sup>
3144
3145域服务器配置管理类。
3146
3147### addServerConfig<sup>18+</sup>
3148
3149static addServerConfig(parameters: Record&lt;string, Object&gt;): Promise&lt;DomainServerConfig&gt;
3150
3151添加域服务器配置。使用Promise异步回调。
3152
3153**系统能力:** SystemCapability.Account.OsAccount
3154
3155**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3156
3157**参数:**
3158
3159| 参数名    | 类型                     | 必填 | 说明                      |
3160| ----------| ----------------------- | --- | -------------------------- |
3161| parameters   | Record<string, Object>  | 是  | 表示域服务器配置参数。 |
3162
3163**返回值:**
3164
3165| 类型                      | 说明                     |
3166| :------------------------ | ----------------------- |
3167| Promise&lt;[DomainServerConfig](#domainserverconfig18)&gt; | Promise对象,返回新添加的域服务器配置。 |
3168
3169**错误码:**
3170
3171以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3172
3173| 错误码ID | 错误信息                     |
3174| -------- | --------------------------- |
3175| 201 | Permission denied.|
3176| 801 | Capability not supported.|
3177| 12300001 | The system service works abnormally. |
3178| 12300002 | Invalid server config parameters. |
3179| 12300211 | Server unreachable. |
3180| 12300213 | Server config already exists. |
3181| 12300215 | The number of server config reaches the upper limit. |
3182
3183**示例:**
3184  ```ts
3185  import { BusinessError } from '@kit.BasicServicesKit';
3186  let configParams: Record<string, Object> = {
3187    'uri': 'test.example.com',
3188    'port': 100
3189  };
3190  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
3191    serverConfig: osAccount.DomainServerConfig) => {
3192    console.info('add server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
3193  }).catch((err: BusinessError) => {
3194    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3195  });
3196  ```
3197
3198### removeServerConfig<sup>18+</sup>
3199
3200static removeServerConfig(configId: string): Promise&lt;void&gt;
3201
3202删除域服务器配置。使用Promise异步回调。
3203
3204**系统能力:** SystemCapability.Account.OsAccount
3205
3206**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3207
3208**参数:**
3209
3210| 参数名    | 类型                     | 必填 | 说明                      |
3211| ----------| ----------------------- | --- | -------------------------- |
3212| configId   | string  | 是  | 表示服务器配置标识。 |
3213
3214**返回值:**
3215
3216| 类型                      | 说明                     |
3217| :------------------------ | ----------------------- |
3218| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
3219
3220**错误码:**
3221
3222以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3223
3224| 错误码ID | 错误信息                     |
3225| -------- | --------------------------- |
3226| 201 | Permission denied.|
3227| 801 | Capability not supported.|
3228| 12300001 | The system service works abnormally. |
3229| 12300212 | Server config not found. |
3230| 12300214 | Server config has been associated with an account. |
3231
3232**示例:**
3233  ```ts
3234  import { BusinessError } from '@kit.BasicServicesKit';
3235  let configParams: Record<string, Object> = {
3236    'uri': 'test.example.com',
3237    'port': 100
3238  };
3239  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
3240    serverConfig: osAccount.DomainServerConfig) => {
3241    console.info('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
3242    osAccount.DomainServerConfigManager.removeServerConfig(serverConfig.id);
3243    console.info('remove domain server configuration successfully');
3244  }).catch((err: BusinessError) => {
3245    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3246  });
3247  ```
3248
3249### updateServerConfig<sup>18+</sup>
3250
3251static updateServerConfig(configId: string, parameters: Record&lt;string, Object&gt;): Promise&lt;DomainServerConfig&gt;
3252
3253更新域服务器配置。使用Promise异步回调。
3254
3255**系统能力:** SystemCapability.Account.OsAccount
3256
3257**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3258
3259**参数:**
3260
3261| 参数名    | 类型                     | 必填 | 说明                      |
3262| ----------| ----------------------- | --- | -------------------------- |
3263| configId   | string  | 是  | 表示服务器配置标识。 |
3264| parameters   | Record&lt;string, Object&gt;  | 是  | 表示域服务器配置参数。 |
3265
3266**返回值:**
3267
3268| 类型                      | 说明                     |
3269| :------------------------ | ----------------------- |
3270| Promise&lt;[DomainServerConfig](#domainserverconfig18)&gt; | Promise对象,返回更新后的域服务器配置。 |
3271
3272**错误码:**
3273
3274以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3275
3276| 错误码ID | 错误信息                     |
3277| -------- | --------------------------- |
3278| 201 | Permission denied.|
3279| 801 | Capability not supported.|
3280| 12300001 | The system service works abnormally. |
3281| 12300002 | Invalid server config parameters. |
3282| 12300211 | Server unreachable. |
3283| 12300212 | Server config not found. |
3284| 12300213 | Server config already exists. |
3285| 12300214 | Server config has been associated with an account. |
3286
3287**示例:**
3288  ```ts
3289  import { BusinessError } from '@kit.BasicServicesKit';
3290  let configParams: Record<string, Object> = {
3291    'uri': 'test.example.com',
3292    'port': 100
3293  };
3294  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
3295    serverConfig: osAccount.DomainServerConfig) => {
3296    console.info('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
3297    osAccount.DomainServerConfigManager.updateServerConfig(serverConfig.id, configParams).then((data) => {
3298      console.info('update domain server configuration successfully, return config: ' + JSON.stringify(data));
3299    }).catch((err: BusinessError) => {
3300      console.error(`update domain server configuration failed, code is ${err.code}, message is ${err.message}`);
3301    });
3302  }).catch((err: BusinessError) => {
3303    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3304  });
3305  ```
3306
3307### getServerConfig<sup>18+</sup>
3308
3309static getServerConfig(configId: string): Promise&lt;DomainServerConfig&gt;
3310
3311获取域服务器配置。使用Promise异步回调。
3312
3313**系统能力:** SystemCapability.Account.OsAccount
3314
3315**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3316
3317**参数:**
3318
3319| 参数名    | 类型                     | 必填 | 说明                      |
3320| ----------| ----------------------- | --- | -------------------------- |
3321| configId   | string  | 是  | 表示服务器配置标识。 |
3322
3323**返回值:**
3324
3325| 类型                      | 说明                     |
3326| :------------------------ | ----------------------- |
3327| Promise&lt;[DomainServerConfig](#domainserverconfig18)&gt; | Promise对象,返回获取的域服务器配置。 |
3328
3329**错误码:**
3330
3331以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3332
3333| 错误码ID | 错误信息                     |
3334| -------- | --------------------------- |
3335| 201 | Permission denied.|
3336| 801 | Capability not supported.|
3337| 12300001 | The system service works abnormally. |
3338| 12300212 | Server config not found. |
3339
3340**示例:**
3341  ```ts
3342  import { BusinessError } from '@kit.BasicServicesKit';
3343  let configParams: Record<string, Object> = {
3344    'uri': 'test.example.com',
3345    'port': 100
3346  };
3347  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
3348    serverConfig: osAccount.DomainServerConfig) => {
3349    console.info('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
3350    osAccount.DomainServerConfigManager.getServerConfig(serverConfig.id).then((data: osAccount.DomainServerConfig) => {
3351      console.info('get domain server configuration successfully, return config: ' + JSON.stringify(data));
3352    }).catch((err: BusinessError) => {
3353      console.error(`get domain server configuration failed, code is ${err.code}, message is ${err.message}`);
3354    });
3355  }).catch((err: BusinessError) => {
3356    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3357  });
3358  ```
3359
3360### getAllServerConfigs<sup>18+</sup>
3361
3362static getAllServerConfigs(): Promise&lt;Array&lt;DomainServerConfig&gt;&gt;
3363
3364获取所有域服务器配置。使用Promise异步回调。
3365
3366**系统能力:** SystemCapability.Account.OsAccount
3367
3368**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3369
3370**返回值:**
3371
3372| 类型                      | 说明                     |
3373| :------------------------ | ----------------------- |
3374| Promise&lt;Array&lt;[DomainServerConfig](#domainserverconfig18)&gt;&gt; | Promise对象,返回获取的所有域服务器配置。 |
3375
3376**错误码:**
3377
3378以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3379
3380| 错误码ID | 错误信息                     |
3381| -------- | --------------------------- |
3382| 201 | Permission denied.|
3383| 801 | Capability not supported.|
3384| 12300001 | The system service works abnormally. |
3385
3386**示例:**
3387  ```ts
3388  import { BusinessError } from '@kit.BasicServicesKit';
3389  let configParams: Record<string, Object> = {
3390    'uri': 'test.example.com',
3391    'port': 100
3392  };
3393  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
3394    serverConfig: osAccount.DomainServerConfig) => {
3395    console.info('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
3396    osAccount.DomainServerConfigManager.getAllServerConfigs().then((data: Array<osAccount.DomainServerConfig>) => {
3397      console.info('get all domain server configuration successfully, return config: ' + JSON.stringify(data));
3398    }).catch((err: BusinessError) => {
3399      console.error(`get all domain server configuration failed, code is ${err.code}, message is ${err.message}`);
3400    });
3401  }).catch((err: BusinessError) => {
3402    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3403  });
3404  ```
3405
3406### getAccountServerConfig<sup>18+</sup>
3407
3408static getAccountServerConfig(domainAccountInfo: DomainAccountInfo): Promise&lt;DomainServerConfig&gt;
3409
3410获取目标域账号的服务器配置。使用Promise异步回调。
3411
3412**系统能力:** SystemCapability.Account.OsAccount
3413
3414**需要权限:** ohos.permission.MANAGE_DOMAIN_ACCOUNT_SERVER_CONFIGS
3415
3416**参数:**
3417
3418| 参数名    | 类型                     | 必填 | 说明                      |
3419| ----------| ----------------------- | --- | -------------------------- |
3420| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是  | 表示目标域账号信息。 |
3421
3422**返回值:**
3423
3424| 类型                      | 说明                     |
3425| :------------------------ | ----------------------- |
3426| Promise&lt;[DomainServerConfig](#domainserverconfig18)&gt; | Promise对象,返回目标账号的域服务器配置。 |
3427
3428**错误码:**
3429
3430以下错误码的详细介绍请参见[账号管理错误码](errorcode-account.md)和[通用错误码](../errorcode-universal.md)。
3431
3432| 错误码ID | 错误信息                     |
3433| -------- | --------------------------- |
3434| 201 | Permission denied.|
3435| 801 | Capability not supported.|
3436| 12300001 | The system service works abnormally. |
3437| 12300003 | Domain account not found. |
3438
3439**示例:**
3440  ```ts
3441  import { BusinessError } from '@kit.BasicServicesKit';
3442  let accountInfo: osAccount.DomainAccountInfo = {
3443    'accountName': 'demoName',
3444    'domain': 'demoDomain'
3445  };
3446  osAccount.DomainServerConfigManager.getAccountServerConfig(accountInfo).then((
3447    serverConfig: osAccount.DomainServerConfig) => {
3448    console.info('get account server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
3449  }).catch((err: BusinessError) => {
3450    console.error(`add server configuration failed, code is ${err.code}, message is ${err.message}`);
3451  });
3452  ```
3453
3454## 系统账号约束列表
3455
3456| 约束                                  | 说明                           |
3457| ------------------------------------- | ------------------------------ |
3458| constraint.wifi                       | 禁止使用Wi-Fi                  |
3459| constraint.wifi.set                   | 禁止配置Wi-Fi                  |
3460| constraint.locale.set                 | 禁止配置设备语言               |
3461| constraint.app.accounts               | 禁止添加和删除应用账号         |
3462| constraint.apps.install               | 禁止安装应用                   |
3463| constraint.apps.uninstall             | 禁止卸载应用                   |
3464| constraint.location.shared            | 禁止打开位置共享               |
3465| constraint.unknown.sources.install    | 禁止安装未知来源的应用         |
3466| constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 |
3467| constraint.bluetooth.set              | 禁止配置蓝牙                   |
3468| constraint.bluetooth | 禁止使用蓝牙 |
3469| constraint.bluetooth.share | 禁止共享使用蓝牙 |
3470| constraint.usb.file.transfer | 禁止通过USB传输文件 |
3471| constraint.credentials.set | 禁止配置用户凭据 |
3472| constraint.os.account.remove | 禁止删除用户 |
3473| constraint.managed.profile.remove | 禁止删除此用户的托管配置文件 |
3474| constraint.debug.features.use | 禁止启用或访问调试功能 |
3475| constraint.vpn.set | 禁止配置VPN |
3476| constraint.date.time.set | 禁止配置日期时间和时区 |
3477| constraint.tethering.config | 禁止配置Tethering |
3478| constraint.network.reset | 禁止重置网络设置 |
3479| constraint.factory.reset | 禁止出厂设置 |
3480| constraint.os.account.create | 禁止创建新用户 |
3481| constraint.add.managed.profile | 禁止添加托管配置文件 |
3482| constraint.apps.verify.disable | 强制应用程序验证 |
3483| constraint.cell.broadcasts.set | 禁止配置小区广播 |
3484| constraint.mobile.networks.set | 禁止配置移动网络 |
3485| constraint.control.apps | 禁止在设置或启动模块中修改应用程序 |
3486| constraint.physical.media | 禁止装载物理外部介质 |
3487| constraint.microphone | 禁止使用麦克风 |
3488| constraint.microphone.unmute | 禁止取消麦克风静音 |
3489| constraint.volume.adjust | 禁止调整音量 |
3490| constraint.calls.outgoing | 禁止拨打外呼电话 |
3491| constraint.sms.use | 禁止发送或接收短信 |
3492| constraint.fun | 禁止享受乐趣 |
3493| constraint.windows.create | 禁止创建应用程序窗口以外的窗口 |
3494| constraint.system.error.dialogs | 禁止显示崩溃或无响应应用程序的系统错误对话框 |
3495| constraint.cross.profile.copy.paste | 禁止通过将数据粘贴到其他用户或配置文件来导出剪贴板内容 |
3496| constraint.beam.outgoing | 禁止使用NFC从应用程序传送数据 |
3497| constraint.wallpaper | 禁止管理壁纸 |
3498| constraint.safe.boot | 禁止进入安全引导模式 |
3499| constraint.parent.profile.app.linking | 禁止父配置文件中的应用程序处理来自托管配置文件的Web链接 |
3500| constraint.audio.record | 禁止录制音频 |
3501| constraint.camera.use | 禁止使用摄像机 |
3502| constraint.os.account.background.run | 禁止在后台运行 |
3503| constraint.data.roam | 禁止漫游通话时使用蜂窝数据 |
3504| constraint.os.account.set.icon | 禁止修改用户头像 |
3505| constraint.wallpaper.set | 禁止设置壁纸 |
3506| constraint.oem.unlock | 禁止启用oem解锁 |
3507| constraint.device.unmute | 禁止取消设备静音 |
3508| constraint.password.unified | 禁止托管配置文件与主用户进行统一锁屏质询 |
3509| constraint.autofill | 禁止使用自动填充服务 |
3510| constraint.content.capture | 禁止捕获用户屏幕 |
3511| constraint.content.suggestions | 禁止接收内容建议 |
3512| constraint.os.account.activate | 禁止前台启动用户 |
3513| constraint.location.set | 禁止配置位置服务 |
3514| constraint.airplane.mode.set | 禁止飞行模式 |
3515| constraint.brightness.set | 禁止配置亮度 |
3516| constraint.share.into.profile | 禁止将主要用户的文件/图片/数据共享到托管配置文件中 |
3517| constraint.ambient.display | 禁止显示环境 |
3518| constraint.screen.timeout.set | 禁止配置屏幕关闭的超时 |
3519| constraint.print | 禁止打印 |
3520| constraint.private.dns.set | 禁止配置专用DNS |
3521