Find if linux machine is domain joined
Solution 1:
A successful kinit -k host/$(hostname -f)
should be sufficient.
This checks to see both if the keytab exists and is valid.
Solution 2:
I think you could just check the return code of the following command:
realm list | grep active-directory
It should return 1 if there are no domains connected.
Solution 3:
You can use the adcli testjoin
,
adcli testjoin
adcli testjoin
uses the current credentials in the keytab and tries to authenticate with the machine account to the AD domain. If this works the machine account password and the join are still valid.
or realm list
.
realm list
List all the discovered and configured realms.