1e41f4b71Sopenharmony_ci# @ohos.enterprise.networkManager (Network Management) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **networkManager** module provides APIs for network management of enterprise devices, including obtaining the device IP address and MAC address. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is enabled. 12e41f4b71Sopenharmony_ci> 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## Modules to Import 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci```ts 17e41f4b71Sopenharmony_ciimport { networkManager } from '@kit.MDMKit'; 18e41f4b71Sopenharmony_ci``` 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci## networkManager.getAllNetworkInterfacesSync 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_cigetAllNetworkInterfacesSync(admin: Want): Array<string> 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ciObtains all activated network ports through the specified device administrator application. 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Parameters** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 34e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------- | ---- | -------------- | 35e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**Return value** 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci| Type | Description | 40e41f4b71Sopenharmony_ci| ------------------- | ---------------------- | 41e41f4b71Sopenharmony_ci| Array<string> | Network ports obtained.| 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci**Error codes** 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci| ID| Error Message | 48e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 49e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 50e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 51e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 52e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**Example** 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci```ts 57e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 58e41f4b71Sopenharmony_cilet wantTemp: Want = { 59e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 60e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 61e41f4b71Sopenharmony_ci}; 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_citry { 64e41f4b71Sopenharmony_ci let result: Array<string> = networkManager.getAllNetworkInterfacesSync(wantTemp); 65e41f4b71Sopenharmony_ci console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`); 66e41f4b71Sopenharmony_ci} catch (err) { 67e41f4b71Sopenharmony_ci console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`); 68e41f4b71Sopenharmony_ci} 69e41f4b71Sopenharmony_ci``` 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci## networkManager.getIpAddressSync 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_cigetIpAddressSync(admin: Want, networkInterface: string): string 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ciObtains the device IP address based on the network port through the specified device administrator application. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Parameters** 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 85e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | -------------- | 86e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 87e41f4b71Sopenharmony_ci| networkInterface | string | Yes | Network port.| 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**Return value** 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci| Type | Description | 92e41f4b71Sopenharmony_ci| ------ | ---------------- | 93e41f4b71Sopenharmony_ci| string | Device IP address obtained.| 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**Error codes** 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci| ID| Error Message | 100e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 101e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 102e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 103e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 104e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci**Example** 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci```ts 109e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 110e41f4b71Sopenharmony_cilet wantTemp: Want = { 111e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 112e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 113e41f4b71Sopenharmony_ci}; 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_citry { 116e41f4b71Sopenharmony_ci let result: string = networkManager.getIpAddressSync(wantTemp, 'eth0'); 117e41f4b71Sopenharmony_ci console.info(`Succeeded in getting ip address, result : ${result}`); 118e41f4b71Sopenharmony_ci} catch (err) { 119e41f4b71Sopenharmony_ci console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`); 120e41f4b71Sopenharmony_ci} 121e41f4b71Sopenharmony_ci``` 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci## networkManager.getMacSync 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_cigetMacSync(admin: Want, networkInterface: string): string 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ciObtains the device MAC address based on the network port through the specified device administrator application. 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci**Parameters** 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 137e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | -------------- | 138e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 139e41f4b71Sopenharmony_ci| networkInterface | string | Yes | Network port.| 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Return value** 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci| Type | Description | 144e41f4b71Sopenharmony_ci| ------ | ----------------- | 145e41f4b71Sopenharmony_ci| string | Device MAC address obtained.| 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Error codes** 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci| ID| Error Message | 152e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 153e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 154e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 155e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 156e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**Example** 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci```ts 161e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 162e41f4b71Sopenharmony_cilet wantTemp: Want = { 163e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 164e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 165e41f4b71Sopenharmony_ci}; 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_citry { 168e41f4b71Sopenharmony_ci let result: string = networkManager.getMacSync(wantTemp, 'eth0'); 169e41f4b71Sopenharmony_ci console.info(`Succeeded in getting mac, result : ${result}`); 170e41f4b71Sopenharmony_ci} catch (err) { 171e41f4b71Sopenharmony_ci console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`); 172e41f4b71Sopenharmony_ci} 173e41f4b71Sopenharmony_ci``` 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ci## networkManager.isNetworkInterfaceDisabledSync 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ciisNetworkInterfaceDisabledSync(admin: Want, networkInterface: string): boolean 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ciChecks whether a network port is disabled through the specified device administrator application. 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci**Parameters** 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 189e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | -------------- | 190e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 191e41f4b71Sopenharmony_ci| networkInterface | string | Yes | Network port.| 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci**Return value** 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci| Type | Description | 196e41f4b71Sopenharmony_ci| ------- | ------------------------------------------------------------ | 197e41f4b71Sopenharmony_ci| boolean | Returns **true** if the network port is disabled; returns **false** otherwise.| 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci**Error codes** 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci| ID| Error Message | 204e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 205e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 206e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 207e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 208e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci**Example** 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci```ts 213e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 214e41f4b71Sopenharmony_cilet wantTemp: Want = { 215e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 216e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 217e41f4b71Sopenharmony_ci}; 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_citry { 220e41f4b71Sopenharmony_ci let result: boolean = networkManager.isNetworkInterfaceDisabledSync(wantTemp, 'eth0'); 221e41f4b71Sopenharmony_ci console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`); 222e41f4b71Sopenharmony_ci} catch (err) { 223e41f4b71Sopenharmony_ci console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`); 224e41f4b71Sopenharmony_ci} 225e41f4b71Sopenharmony_ci``` 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci## networkManager.setNetworkInterfaceDisabledSync 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_cisetNetworkInterfaceDisabledSync(admin: Want, networkInterface: string, isDisabled: boolean): void 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ciDisables a network port through the specified device administrator application. 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci**Parameters** 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 241e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | ------------------------------------------------- | 242e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 243e41f4b71Sopenharmony_ci| networkInterface | string | Yes | Network port. | 244e41f4b71Sopenharmony_ci| isDisabled | boolean | Yes | Network port status to set. The value **true** means to disable the network port, and **false** means to enable the network port.| 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**Error codes** 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci| ID| Error Message | 251e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 252e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 253e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 254e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 255e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci**Example** 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci```ts 260e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 261e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 262e41f4b71Sopenharmony_cilet wantTemp: Want = { 263e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 264e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 265e41f4b71Sopenharmony_ci}; 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_citry { 268e41f4b71Sopenharmony_ci networkManager.setNetworkInterfaceDisabledSync(wantTemp, 'eth0', true); 269e41f4b71Sopenharmony_ci console.info(`Succeeded in setting network interface disabled`); 270e41f4b71Sopenharmony_ci} catch (err) { 271e41f4b71Sopenharmony_ci console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`); 272e41f4b71Sopenharmony_ci} 273e41f4b71Sopenharmony_ci``` 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci## networkManager.setGlobalProxySync 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_cisetGlobalProxySync(admin: Want, httpProxy: connection.HttpProxy): void 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ciSets the global network proxy through the specified device administrator application. 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci**Parameters** 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 289e41f4b71Sopenharmony_ci| --------- | ------------------------------------------------------------ | ---- | -------------------------- | 290e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 291e41f4b71Sopenharmony_ci| httpProxy | [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10) | Yes | Global HTTP proxy to set.| 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci**Error codes** 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci| ID| Error Message | 298e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 299e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 300e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 301e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 302e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**Example** 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci```ts 307e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 308e41f4b71Sopenharmony_ciimport { connection } from '@kit.NetworkKit'; 309e41f4b71Sopenharmony_cilet wantTemp: Want = { 310e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 311e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 312e41f4b71Sopenharmony_ci}; 313e41f4b71Sopenharmony_cilet exclusionStr: string = "192.168,baidu.com" 314e41f4b71Sopenharmony_cilet exclusionArray: Array<string> = exclusionStr.split(','); 315e41f4b71Sopenharmony_cilet httpProxy: connection.HttpProxy = { 316e41f4b71Sopenharmony_ci host: "192.168.xx.xxx", 317e41f4b71Sopenharmony_ci port: 8080, 318e41f4b71Sopenharmony_ci exclusionList: exclusionArray 319e41f4b71Sopenharmony_ci}; 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_citry { 322e41f4b71Sopenharmony_ci networkManager.setGlobalProxySync(wantTemp, httpProxy); 323e41f4b71Sopenharmony_ci console.info(`Succeeded in setting network global proxy.`); 324e41f4b71Sopenharmony_ci} catch (err) { 325e41f4b71Sopenharmony_ci console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`); 326e41f4b71Sopenharmony_ci} 327e41f4b71Sopenharmony_ci``` 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci## networkManager.getGlobalProxySync 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_cigetGlobalProxySync(admin: Want): connection.HttpProxy 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ciObtains the global network proxy through the specified device administrator application. 334e41f4b71Sopenharmony_ci 335e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci**Parameters** 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 343e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------- | ---- | -------------- | 344e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci**Return value** 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci| Type | Description | 349e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------ | 350e41f4b71Sopenharmony_ci| [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10) | Global HTTP proxy configuration obtained.| 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci**Error codes** 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci| ID| Error Message | 357e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 358e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 359e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 360e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 361e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci**Example** 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci```ts 366e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 367e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 368e41f4b71Sopenharmony_ciimport { connection } from '@kit.NetworkKit'; 369e41f4b71Sopenharmony_cilet wantTemp: Want = { 370e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 371e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 372e41f4b71Sopenharmony_ci}; 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_citry { 375e41f4b71Sopenharmony_ci let result: connection.HttpProxy = networkManager.getGlobalProxySync(wantTemp); 376e41f4b71Sopenharmony_ci console.info(`Succeeded in getting network global proxy, result : ${JSON.stringify(result)}`); 377e41f4b71Sopenharmony_ci} catch (err) { 378e41f4b71Sopenharmony_ci console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`); 379e41f4b71Sopenharmony_ci} 380e41f4b71Sopenharmony_ci``` 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci## networkManager.addFirewallRule 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ciaddFirewallRule(admin: Want, firewallRule: FirewallRule): void 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ciAdds a firewall rule for devices through the specified device administrator application.<br> 387e41f4b71Sopenharmony_ciAfter a rule with [Action](#action) set to **ALLOW** is added, a rule with **Action** set to **DENY** is added by default to discard or intercept all network data packets that do not meet the **ALLOW** rule. 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ci**Parameters** 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 397e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------- | ---- | -------------------- | 398e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 399e41f4b71Sopenharmony_ci| firewallRule | [FirewallRule](#firewallrule) | Yes | Firewall rule to add.| 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**Error codes** 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci| ID| Error Message | 406e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 407e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 408e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 409e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 410e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci**Example** 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci```ts 415e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 416e41f4b71Sopenharmony_ci 417e41f4b71Sopenharmony_cilet wantTemp: Want = { 418e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 419e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 420e41f4b71Sopenharmony_ci}; 421e41f4b71Sopenharmony_cilet firewallRule: networkManager.FirewallRule = { 422e41f4b71Sopenharmony_ci "srcAddr": "192.168.1.1-192.188.22.66", 423e41f4b71Sopenharmony_ci "destAddr": "10.1.1.1", 424e41f4b71Sopenharmony_ci "srcPort": "8080", 425e41f4b71Sopenharmony_ci "destPort": "8080", 426e41f4b71Sopenharmony_ci "appUid": "9696", 427e41f4b71Sopenharmony_ci "direction": networkManager.Direction.OUTPUT, 428e41f4b71Sopenharmony_ci "action": networkManager.Action.DENY, 429e41f4b71Sopenharmony_ci "protocol": networkManager.Protocol.UDP, 430e41f4b71Sopenharmony_ci} 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_cinetworkManager.addFirewallRule(wantTemp, firewallRule); 433e41f4b71Sopenharmony_ci``` 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci## networkManager.removeFirewallRule 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ciremoveFirewallRule(admin: Want, firewallRule?: FirewallRule): void 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ciRemoves a firewall rule for devices through the specified device administrator application.<br> 440e41f4b71Sopenharmony_ciIf there is no rule with [Action](#action) being **ALLOW** after the rule is removed, the **DENY** rules that are added by default with [addFirewallRule](#networkmanageraddfirewallrule) will be removed. 441e41f4b71Sopenharmony_ci 442e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 445e41f4b71Sopenharmony_ci 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci**Parameters** 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 450e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------- | ---- | ---------------------------------------------------- | 451e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 452e41f4b71Sopenharmony_ci| firewallRule | [FirewallRule](#firewallrule) | No | Firewall rule to remove. If the value is empty, all firewall rules will be removed.| 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci**Error codes** 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci| ID| Error Message | 459e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 460e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 461e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 462e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 463e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci**Example** 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_ci```ts 468e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_cilet wantTemp: Want = { 471e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 472e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 473e41f4b71Sopenharmony_ci}; 474e41f4b71Sopenharmony_ci// Remove the specified firewall rule. 475e41f4b71Sopenharmony_cilet firewallRule: networkManager.FirewallRule = { 476e41f4b71Sopenharmony_ci "srcAddr": "192.168.1.1-192.188.22.66", 477e41f4b71Sopenharmony_ci "destAddr": "10.1.1.1", 478e41f4b71Sopenharmony_ci "srcPort": "8080", 479e41f4b71Sopenharmony_ci "destPort": "8080", 480e41f4b71Sopenharmony_ci "appUid": "9696", 481e41f4b71Sopenharmony_ci "direction": networkManager.Direction.OUTPUT, 482e41f4b71Sopenharmony_ci "action": networkManager.Action.DENY, 483e41f4b71Sopenharmony_ci "protocol": networkManager.Protocol.UDP, 484e41f4b71Sopenharmony_ci} 485e41f4b71Sopenharmony_cinetworkManager.removeFirewallRule(wantTemp, firewallRule); 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci// Remove all firewall rules. 488e41f4b71Sopenharmony_cinetworkManager.removeFirewallRule(wantTemp); 489e41f4b71Sopenharmony_ci``` 490e41f4b71Sopenharmony_ci 491e41f4b71Sopenharmony_ci## networkManager.getFirewallRules 492e41f4b71Sopenharmony_ci 493e41f4b71Sopenharmony_cigetFirewallRules(admin: Want): Array\<FirewallRule> 494e41f4b71Sopenharmony_ci 495e41f4b71Sopenharmony_ciObtains firewall rules through the specified device administrator application. 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 498e41f4b71Sopenharmony_ci 499e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 500e41f4b71Sopenharmony_ci 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ci**Parameters** 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 505e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------- | ---- | -------------- | 506e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 507e41f4b71Sopenharmony_ci 508e41f4b71Sopenharmony_ci**Return value** 509e41f4b71Sopenharmony_ci 510e41f4b71Sopenharmony_ci| Type | Description | 511e41f4b71Sopenharmony_ci| ------------------------------------- | ------------------------------------------------------------ | 512e41f4b71Sopenharmony_ci| Array\<[FirewallRule](#firewallrule)> | A list of firewall rules configured for the device is returned. If the operation fails, an exception will be thrown.| 513e41f4b71Sopenharmony_ci 514e41f4b71Sopenharmony_ci**Error codes** 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ci| ID| Error Message | 519e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 520e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 521e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 522e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 523e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Example** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci```ts 528e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_cilet wantTemp: Want = { 531e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 532e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 533e41f4b71Sopenharmony_ci}; 534e41f4b71Sopenharmony_cilet firewallRule: Array<networkManager.FirewallRule>; 535e41f4b71Sopenharmony_cifirewallRule = networkManager.getFirewallRules(wantTemp); 536e41f4b71Sopenharmony_ci``` 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci## networkManager.addDomainFilterRule 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ciaddDomainFilterRule(admin: Want, domainFilterRule: DomainFilterRule): void 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ciAdds a domain name filtering rule for the device through the specified device administrator application.<br> 543e41f4b71Sopenharmony_ciAfter a rule with [Action](#action) set to **ALLOW** is added, a rule with **Action** set to **DENY** is added by default to discard or intercept all packets for domain name resolution that do not meet the **ALLOW** rule. 544e41f4b71Sopenharmony_ci 545e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 546e41f4b71Sopenharmony_ci 547e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 548e41f4b71Sopenharmony_ci 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci**Parameters** 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 553e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | ------------------ | 554e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 555e41f4b71Sopenharmony_ci| domainFilterRule | [DomainFilterRule](#domainfilterrule) | Yes | Domain name filtering rule to add.| 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ci**Error codes** 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 560e41f4b71Sopenharmony_ci 561e41f4b71Sopenharmony_ci| ID| Error Message | 562e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 563e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 564e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 565e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 566e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 567e41f4b71Sopenharmony_ci 568e41f4b71Sopenharmony_ci**Example** 569e41f4b71Sopenharmony_ci 570e41f4b71Sopenharmony_ci```ts 571e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_cilet wantTemp: Want = { 574e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 575e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 576e41f4b71Sopenharmony_ci}; 577e41f4b71Sopenharmony_cilet domainFilterRule: networkManager.DomainFilterRule = { 578e41f4b71Sopenharmony_ci "domainName": "www.example.com", 579e41f4b71Sopenharmony_ci "appUid": "9696", 580e41f4b71Sopenharmony_ci "action": networkManager.Action.DENY, 581e41f4b71Sopenharmony_ci} 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_cinetworkManager.addDomainFilterRule(wantTemp, domainFilterRule); 584e41f4b71Sopenharmony_ci``` 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci## networkManager.removeDomainFilterRule 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ciremoveDomainFilterRule(admin: Want, domainFilterRule?: DomainFilterRule): void 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ciRemoves a domain name filtering rule through the specified device administrator application.<br> 591e41f4b71Sopenharmony_ciIf there is no rule with [Action](#action) being **ALLOW** after the rule is removed, the **DENY** rules that are added by default with [addDomainFilterRule](#networkmanageradddomainfilterrule) will be removed. 592e41f4b71Sopenharmony_ci 593e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 594e41f4b71Sopenharmony_ci 595e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci**Parameters** 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 601e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------- | ---- | ------------------------------------------------ | 602e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 603e41f4b71Sopenharmony_ci| domainFilterRule | [DomainFilterRule](#domainfilterrule) | No | Domain name filtering rule to remove. If the value is empty, all domain name filtering rules will be removed.| 604e41f4b71Sopenharmony_ci 605e41f4b71Sopenharmony_ci**Error codes** 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ci| ID| Error Message | 610e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 611e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 612e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 613e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 614e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 615e41f4b71Sopenharmony_ci 616e41f4b71Sopenharmony_ci**Example** 617e41f4b71Sopenharmony_ci 618e41f4b71Sopenharmony_ci```ts 619e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 620e41f4b71Sopenharmony_ci 621e41f4b71Sopenharmony_cilet wantTemp: Want = { 622e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 623e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 624e41f4b71Sopenharmony_ci}; 625e41f4b71Sopenharmony_ci// Remove the specified domain name filtering rule. 626e41f4b71Sopenharmony_cilet domainFilterRule: networkManager.DomainFilterRule = { 627e41f4b71Sopenharmony_ci "domainName": "www.example.com", 628e41f4b71Sopenharmony_ci "appUid": "9696", 629e41f4b71Sopenharmony_ci "action": networkManager.Action.DENY, 630e41f4b71Sopenharmony_ci} 631e41f4b71Sopenharmony_cinetworkManager.removeDomainFilterRule(wantTemp, domainFilterRule); 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci// Remove all domain name filtering rules. 634e41f4b71Sopenharmony_cinetworkManager.removeDomainFilterRule(wantTemp); 635e41f4b71Sopenharmony_ci``` 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci## networkManager.getDomainFilterRules 638e41f4b71Sopenharmony_ci 639e41f4b71Sopenharmony_cigetDomainFilterRules(admin: Want): Array\<DomainFilterRule> 640e41f4b71Sopenharmony_ci 641e41f4b71Sopenharmony_ciObtains domain name filtering rules through the specified device administrator application. 642e41f4b71Sopenharmony_ci 643e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 646e41f4b71Sopenharmony_ci 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ci**Parameters** 649e41f4b71Sopenharmony_ci 650e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 651e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------- | ---- | -------------- | 652e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 653e41f4b71Sopenharmony_ci 654e41f4b71Sopenharmony_ci**Return value** 655e41f4b71Sopenharmony_ci 656e41f4b71Sopenharmony_ci| Type | Description | 657e41f4b71Sopenharmony_ci| --------------------------------------------- | ------------------------------------------------------------ | 658e41f4b71Sopenharmony_ci| Array\<[DomainFilterRule](#domainfilterrule)> | A list of domain name filtering rules configured for the device is returned. If the operation fails, an exception will be thrown.| 659e41f4b71Sopenharmony_ci 660e41f4b71Sopenharmony_ci**Error codes** 661e41f4b71Sopenharmony_ci 662e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ci| ID| Error Message | 665e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 666e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 667e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 668e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 669e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ci**Example** 672e41f4b71Sopenharmony_ci 673e41f4b71Sopenharmony_ci```ts 674e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_cilet wantTemp: Want = { 677e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 678e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 679e41f4b71Sopenharmony_ci}; 680e41f4b71Sopenharmony_cilet domainFilterRule: Array<networkManager.DomainFilterRule>; 681e41f4b71Sopenharmony_cidomainFilterRule = networkManager.getDomainFilterRules(wantTemp); 682e41f4b71Sopenharmony_ci``` 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ci## FirewallRule 685e41f4b71Sopenharmony_ci 686e41f4b71Sopenharmony_ciRepresents a firewall rule. 687e41f4b71Sopenharmony_ci 688e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 689e41f4b71Sopenharmony_ci 690e41f4b71Sopenharmony_ci 691e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 692e41f4b71Sopenharmony_ci| --------- | ----------------------- | ---- | ------------------------------------------------------------ | 693e41f4b71Sopenharmony_ci| srcAddr | string | No | Source IP address. An IP address segment, for example, **192.168.0.0/22** or **192.168.1.100-192.168.1.200** is supported.| 694e41f4b71Sopenharmony_ci| destAddr | string | No | Destination IP address. An IP address segment, for example, **192.168.0.0/22** or **192.168.1.100-192.168.1.200** is supported.| 695e41f4b71Sopenharmony_ci| srcPort | string | No | Source port. | 696e41f4b71Sopenharmony_ci| destPort | string | No | Destination port. | 697e41f4b71Sopenharmony_ci| appUid | string | No | UID of the application. | 698e41f4b71Sopenharmony_ci| direction | [Direction](#direction) | No | Direction chains to which the rule applies.<br>This parameter is mandatory when you add a firewall rule. If it is not specified when you remove a firewall rule, all [direction](#direction) chains will be removed.<br>If this parameter is empty, **srcAddr**, **destAddr**, **srcPort**, **destPort**, and **appUid** must also be empty.| 699e41f4b71Sopenharmony_ci| action | [Action](#action) | No | Action to take, that is, receive or discard data packets.<br>This parameter is mandatory when a firewall rule is added. It is optional when a firewall rule is removed. If it is not specified, all chains that match the [Action](#action) rule will be removed.<br>If this parameter is empty, **srcAddr**, **destAddr**, **srcPort**, **destPort**, and **appUid** must also be empty.| 700e41f4b71Sopenharmony_ci| protocol | [Protocol](#protocol) | No | Network protocol. If this parameter is set to **ALL** or **ICMP**, **srcPort** and **destPort** cannot be set.| 701e41f4b71Sopenharmony_ci 702e41f4b71Sopenharmony_ci## DomainFilterRule 703e41f4b71Sopenharmony_ci 704e41f4b71Sopenharmony_ciRepresents a domain name filtering rule. 705e41f4b71Sopenharmony_ci 706e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 707e41f4b71Sopenharmony_ci 708e41f4b71Sopenharmony_ci 709e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 710e41f4b71Sopenharmony_ci| ---------- | ----------------- | ---- | ------------------------------------------------------------ | 711e41f4b71Sopenharmony_ci| domainName | string | No | Domain name. This parameter is mandatory when a domain name filtering rule is added. | 712e41f4b71Sopenharmony_ci| appUid | string | No | UID of the application. | 713e41f4b71Sopenharmony_ci| action | [Action](#action) | No | Action to take, that is, receive or discard data packets.<br>This parameter is mandatory when you add a domain name filtering rule. If it is not specified when you remove a domain name filtering rule, all chains that match the [Action](#action) rule will be removed.<br>If this parameter is empty, **domainName** and **appUid** must also be empty.| 714e41f4b71Sopenharmony_ci 715e41f4b71Sopenharmony_ci## Direction 716e41f4b71Sopenharmony_ci 717e41f4b71Sopenharmony_ciDirection chains to which the rule applies. 718e41f4b71Sopenharmony_ci 719e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_ci 722e41f4b71Sopenharmony_ci| Name | Value | Description | 723e41f4b71Sopenharmony_ci| ------ | ---- | -------- | 724e41f4b71Sopenharmony_ci| INPUT | 0 | Input chain.| 725e41f4b71Sopenharmony_ci| OUTPUT | 1 | Output chain.| 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci## Action 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ciEnumerates the actions that can be taken for data packets. 730e41f4b71Sopenharmony_ci 731e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 732e41f4b71Sopenharmony_ci 733e41f4b71Sopenharmony_ci 734e41f4b71Sopenharmony_ci| Name | Value | Description | 735e41f4b71Sopenharmony_ci| ----- | ---- | ------------ | 736e41f4b71Sopenharmony_ci| ALLOW | 0 | Receive data packets.| 737e41f4b71Sopenharmony_ci| DENY | 1 | Discard data packets.| 738e41f4b71Sopenharmony_ci 739e41f4b71Sopenharmony_ci## Protocol 740e41f4b71Sopenharmony_ci 741e41f4b71Sopenharmony_ciNetwork protocol. 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ci 746e41f4b71Sopenharmony_ci| Name| Value | Description | 747e41f4b71Sopenharmony_ci| ---- | ---- | -------------- | 748e41f4b71Sopenharmony_ci| ALL | 0 | All network protocols.| 749e41f4b71Sopenharmony_ci| TCP | 1 | TCP. | 750e41f4b71Sopenharmony_ci| UDP | 2 | UDP. | 751e41f4b71Sopenharmony_ci| ICMP | 3 | ICMP.| 752