Join macOS to Active Directory

Simply execute following commands:

$ dsconfigad -domain <domain_name> -a <hostname> -u <domain_admin_user>
$ dsconfigad -groups "domain admins","enterprise admins","my custom admin group"
$ dsconfigad -mobile enable -mobileconfirm disable

The first command will join the computer to the domain. Please make sure you are using the hostname given by the hostname command, not the one defined in the sharing settings and the user which you are using for joining has the “domain admins” group by default.

The second command sets all the groups which are allowed to manage the computer

The third command is used to enable mobile logins (must be used in case the computer is not always connected to the domain, e.g. macbooks leaving the network).

More infos on apple’s page:

https://support.apple.com/en-gb/guide/directory-utility/diru11f4f748/6.3/mac/13.0