This topic describes how to configure an Active Directory (AD) domain controller on an Elastic Compute Service (ECS) instance and connect an ApsaraDB RDS for PostgreSQL instance to a self-managed AD domain.
Background information
AD is a directory service that is provided by Microsoft. A directory is a hierarchical structure that stores information about the objects on the same LAN. An enterprise can store data, such as computer accounts, user accounts, and groups, in a directory. This way, the enterprise can improve the security of the data and manage the data in a more convenient manner.
You can connect your RDS instance to a self-managed AD domain. This way, you can manage your enterprise in a centralized manner and can configure IP address whitelists at the database level and the user level to improve the security of your data.
Prerequisites
- Your RDS instance meets the following requirements:
- The RDS instance runs PostgreSQL 10 or later.
- The RDS instance runs a minor engine version of 20210228 or later. For more information about how to update the minor engine version of your RDS instance, see Update the minor engine version of an ApsaraDB RDS for PostgreSQL instance.
- The RDS instance uses cloud disks.
- An ECS instance is created. For more information, see Create an ECS instance. Your RDS instance must access the self-managed AD domain by using a private IP address. Therefore, the ECS instance must meet the following conditions:
- The ECS instance and your RDS instance reside in the same virtual private cloud (VPC).
- The security group to which the ECS instance belongs is configured to allow access from the private IP address of your RDS instance. For more information, see Add security group rules.
- The firewall of the ECS instance is disabled by default. If the firewall is enabled for the ECS instance, you must configure the firewall to allow access from the private IP address of your RDS instance.
- The image of the ECS instance runs Windows Server 2016 or later.
- The domain account belongs to the Domain Admins group.
- Your Alibaba Cloud account is used to log on to the ApsaraDB RDS console.
Procedure
- Configure an AD domain controller for the ECS instance.
- Create an administrator user for the AD domain controller.
- Add a standard user to the AD domain controller for logon. Note You must perform the same operations that are described in Add an administrator user to the AD domain controller. A standard user does not need to be added to the Domain Admins administrator group.
In this example, add a standard user named
ldapuser
to the AD domain controller. This user is used to log on to your RDS instance. - Configure security group rules for the ECS instance.
- Configure your RDS instance.
- (Optional) Import the service information of multiple AD domains at a time. You can also manually add the service information of the AD domain. The following import methods are supported:
- Overwrite existing service information.
- Additional service information (highest priority): If you select this option, the service information of the AD domain is appended to the beginning of the existing service information. The priority of the appended information is higher than the priority of the existing service information.
- Additional service information (lowest priority): If you select this option, the service information of the AD domain is appended to the end of the existing service information. The priority of the appended information is lower than the priority of the existing service information.
Valid format:TYPE|DATABASE|USER1|ADDRESS|MASK|METHOD|OPTION
Enter the service information that you want to import in the Edit AD domain text box. For more information about the parameters, see Parameters.
Sample configuration:host|all|<Username of the standard account of the AD domain>|0.0.0.0/0||ldap|ldapserver=<Private IP address of the ECS instance> ldapbasedn="CN=Users,DC=<Prefix of the root domain name>,DC=<Suffix of the root domain name>" ldapbinddn="CN=<Username of the administrator user of the AD domain>,CN=Users,DC=<Prefix of the root domain name>,DC=<Suffix of the root domain name>" ldapbindpasswd="<Password of the administrator user of the AD domain>" ldapsearchattribute="sAMAccountName". In this example, the prefix of the root domain name is pgsqldomain, and the suffix is net.
- Test the connection. Use a PostgreSQL command-line tool to connect to your RDS instance.Note You can connect to your RDS instance by using multiple methods. In this topic, a PostgreSQL command-line tool is used. You must install PostgreSQL before you use the PostgreSQL command-line tool. For more information, see Connect to an ApsaraDB RDS for PostgreSQL instance.
Run the following command and use the username and password of the standard user of the AD domain controller to connect to your RDS instance:
psql -h <Endpoint of your RDS instance> -U Username of the standard account of the AD domain -p 5432 -d postgres
View the modification history of AD domain service information
- Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
- In the left-side navigation pane, click Accounts. On the page that appears, click the AD Domain Services Edit History tab.
- You can view changedetails in the Actions column. If the modification fails, the status is Not Taking Effect. You can click Change Log to view the error message.