Reputation: 125
I want to print a list of all the hosts connected to the domain.
I'm looking for a command which does more or less what that one in Powershell does, but for Linux:
Get-ADComputer -Filter * | ForEach-Object {$_.Name}
So, what I want to do is getting a list with all the hosts on a domain and then compare it with all the hosts which are already monitored with Nagios.
The computer on which the command will be executed is the Nagios-server (not on the DC itself).
Upvotes: 2
Views: 8682
Reputation: 229204
There's no convenient wrappers that intergrates with Active Directory as the cmdlets you have in powershell. However, Active Directory is an LDAP server, and you can pull out the info with the ldapsearch
tool, this query fetches all the registred computers in out Active Directory domain:
ldapsearch -LLL -H ldap://ad.ourdomain.local -x -D 'OURDOMAIN\user' -w 'thepassword' -b 'dc=ourdomain,dc=local' 'objectClass=computer' name
ad.ourdomain.local
is the host name or IP address of an active directory domain controller.
OURDOMAIN\user
is your domain name, and an existing user name (e.g. ACME\Jon). i.e. the username one uses when logging into a domain account on a windows machine
thepassword
is the password of the above user Jon
dc=OURDOMAIN,dc=local
is the top level LDAP DN, e.g. dc=acme,dc=local
, it might be dc=acme,dc=com`, or something else. I don't know an easy way to figure it out except pulling the info out of ADExplorer
Upvotes: 6