#!/usr/bin/perl
# Copyright (C) 2011-2012 eBox Technologies S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use EBox;
use EBox::Global;
use EBox::Ldap;
use EBox::Config;

EBox::init();

my $usersMod = EBox::Global->modInstance('users');
my $ldap = $usersMod->ldap();
my $dn = $ldap->dn;
my $mode = $usersMod->model('Mode');
my $host = $mode->remoteValue();
my $settings = $usersMod->model('ADSyncSettings');
my $status = $settings->enableADsyncValue();
my $username = $settings->usernameValue();
my $password = $settings->adpassValue();
my $port = EBox::Config::configkey('adsync_port');
my $secret = $settings->secretValue();
my $userDn = "CN=$username,CN=Users,$dn";

print "Zentyal Active Directory sync info:\n";
if ($status) {
print "\tADsync status: ENABLED\n";
} else {
print "\tADsync status: DISABLED\n";
}
print "\tDomain controller: $host\n";
print "\tAD username: $username\n";
print "\tAD password: $password\n";
print "\tZentyal ADsync port: $port\n";
print "\tZentyal ADsync shared secret: $secret\n";
print "\nTo query AD you could use ldapsearch -h $host -b '$dn' -D '$userDn' -x -w '$password' [(filter)]\n";

1;
