1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The *HostAuthenticationManager* managed object provides
/// access to Active Directory configuration information for an
/// ESX host.
///
/// It also provides access to methods for adding a host
/// to or removing a host from an Active Directory domain.
///
/// The vSphere API supports Microsoft Active Directory management
/// of authentication for ESX hosts. To integrate an ESX host
/// into an Active Directory environment, you use an Active
/// Directory account that has the authority to add
/// a computer to a domain. The ESX Server locates the Active
/// Directory domain controller. When you add a host to a domain,
/// you only need to specify the domain and the account
/// user name and password.
///
/// There are two approaches that you can use to add an ESX host
/// to or remove a host from an Active Directory domain.
/// - *HostActiveDirectoryAuthentication.JoinDomain_Task* and
/// *HostActiveDirectoryAuthentication.LeaveCurrentDomain_Task*
/// methods - Your vSphere client application can call
/// these methods directly to add the host to or remove the host
/// from a domain.
/// - Host configuration - Use the *HostActiveDirectory* data object
/// to specify Active Directory configuration, either adding the host to
/// or removing the host from a domain. To apply the Active Directory
/// configuration, use the *HostProfileManager* method
/// (*HostProfileManager.ApplyHostConfig_Task*)
/// to apply the *HostConfigSpec*. When the ESX Server processes
/// the configuration, it will invoke the join or leave method.
///
/// To take advantage of ESX host membership in an Active Directory domain,
/// grant permissions on the ESX host to Active Directory users and groups
/// who should have direct access to management of the ESX host.
/// Use the *UserDirectory*.*UserDirectory.RetrieveUserGroups*
/// method to obtain information about Active Directory users and groups.
/// After retrieving the Active Directory data, you can use the
/// *AuthorizationManager*.*AuthorizationManager.SetEntityPermissions*
/// method to set the *Permission.principal* property
/// to the appropriate user or group.
///
/// By default, the ESX host assigns the Administrator role to the "ESX Admins" group.
/// If the group does not exist when the host joins the domain, the host will
/// not assign the role. In this case, you must create the "ESX Admins"
/// group in the Active Directory. The host will periodically check the domain controller
/// for the group and will assign the role when the group exists.
#[derive(Clone)]
pub struct HostAuthenticationManager {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl HostAuthenticationManager {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Information about Active Directory membership.
pub async fn info(&self) -> Result<crate::types::structs::HostAuthenticationManagerInfo> {
let pv_opt = self.client.fetch_property_raw("", "HostAuthenticationManager", &self.mo_id, "info").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property info was empty".to_string()))?;
let result: crate::types::structs::HostAuthenticationManagerInfo = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// An array that can contain managed object references to local and
/// Active Directory authentication managed objects.
///
/// <code>supportedStore</code> data implies a connection to a system
/// that stores information about accounts.
/// The <code>supportedStore</code> array can include the following objects:
/// - *HostLocalAuthentication* - Local authentication refers
/// to user accounts on the ESX host. Local authentication is always enabled.
/// - *HostActiveDirectoryAuthentication* - Active Directory authentication
/// refers to computer accounts and user accounts on the domain controller.
/// This object indicates the domain membership status for the host
/// and defines the join and leave methods for Active Directory
/// membership.
///
/// If <code>supportedStore</code> references
/// a *HostActiveDirectoryAuthentication* object, the host
/// is capable of joining a domain.
/// However, if you try to add a host to a domain when the
/// *HostAuthenticationStoreInfo*.*HostAuthenticationStoreInfo.enabled*
/// property is <code>True</code> (accessed through the <code>info</code>
/// property), the join method will throw a fault.
///
/// ## Returns:
///
/// Refers instances of *HostAuthenticationStore*.
pub async fn supported_store(&self) -> Result<Vec<crate::types::structs::ManagedObjectReference>> {
let pv_opt = self.client.fetch_property_raw("", "HostAuthenticationManager", &self.mo_id, "supportedStore").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property supportedStore was empty".to_string()))?;
let result: Vec<crate::types::structs::ManagedObjectReference> = crate::core::client::extract_property(pv)?;
Ok(result)
}
}