1692
1693
struct sockaddr_storage dcss;
1693
1694
const char *os_name = NULL;
1694
1695
const char *os_version = NULL;
1696
nt_status = check_ads_config();
1697
if (!NT_STATUS_IS_OK(nt_status)) {
1698
d_fprintf(stderr, "Invalid configuration. Exiting....\n");
1702
/* setup the server affinity cache */
1704
get_dc_name( lp_workgroup(), lp_realm(), dc_name, &dcss );
1706
/* set the time before attempting authentication */
1708
status = ads_startup_nobind( True, &ads );
1709
if ( !ADS_ERR_OK(status) ) {
1710
d_fprintf( stderr, "Failed to contact DC when trying to synchronize local system clock!\n");
1711
if ((status.error_type == ENUM_ADS_ERROR_NT) &&
1712
NT_STATUS_EQUAL(status.err.nt_status,
1713
NT_STATUS_NO_LOGON_SERVERS))
1715
d_fprintf( stderr, "None of the domain controllers listed in DNS could be contacted, or there are no DCs listed in DNS.\n");
1717
ads_destroy( &ads );
1721
server_time = cli_servertime( dc_name, &dcss, NULL );
1722
if ( server_time != 0 ) {
1727
sys_result = stime((const)&server_time);
1729
asprintf(&cmd, "/bin/date %s", systime(server_time));
1731
sys_result = system (cmd);
1735
if (sys_result != 0 ) {
1736
d_fprintf( stderr, "Failed to synchronize local machine clock to "
1737
"domain controller (%s)\n", \
1738
ads->config.ldap_server_name );
1739
/* try to go ahead and join anyways */
1742
ads_destroy( &ads );
1745
/* now begin the real join process */
1747
status = ads_startup(True, &ads);
1748
if (!ADS_ERR_OK(status)) {
1749
DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status)));
1750
nt_status = ads_ntstatus(status);
1754
if (strcmp(ads->config.realm, lp_realm()) != 0) {
1755
d_fprintf(stderr, "realm of remote server (%s) and realm in %s "
1756
"(%s) DO NOT match. Aborting join\n",
1757
ads->config.realm, get_dyn_CONFIGFILE(), lp_realm());
1758
nt_status = NT_STATUS_INVALID_PARAMETER;
1762
if (!(ctx = talloc_init("net_ads_join"))) {
1763
d_fprintf(stderr, "Could not initialise talloc context.\n");
1764
nt_status = NT_STATUS_NO_MEMORY;
1696
bool notimesync = False;
1768
1698
/* process additional command line args */
1736
nt_status = check_ads_config();
1737
if (!NT_STATUS_IS_OK(nt_status)) {
1738
d_fprintf(stderr, "Invalid configuration. Exiting....\n");
1742
/* setup the server affinity cache */
1744
get_dc_name( lp_workgroup(), lp_realm(), dc_name, &dcss );
1746
/* set the time before attempting authentication */
1749
status = ads_startup_nobind( True, &ads );
1750
if ( !ADS_ERR_OK(status) ) {
1751
d_fprintf( stderr, "Failed to contact DC when trying to synchronize local system clock!\n");
1752
if ((status.error_type == ENUM_ADS_ERROR_NT) &&
1753
NT_STATUS_EQUAL(status.err.nt_status,
1754
NT_STATUS_NO_LOGON_SERVERS))
1756
d_fprintf( stderr, "None of the domain controllers listed in DNS could be contacted, or there are no DCs listed in DNS.\n");
1758
ads_destroy( &ads );
1762
server_time = cli_servertime( dc_name, &dcss, NULL );
1763
if ( server_time != 0 ) {
1768
sys_result = stime((const)&server_time);
1770
asprintf(&cmd, "/bin/date %s", systime(server_time));
1772
sys_result = system (cmd);
1776
if (sys_result != 0 ) {
1777
d_fprintf( stderr, "Failed to synchronize local machine clock to "
1778
"domain controller (%s)\n", \
1779
ads->config.ldap_server_name );
1780
/* try to go ahead and join anyways */
1783
ads_destroy( &ads );
1787
/* now begin the real join process */
1789
status = ads_startup(True, &ads);
1790
if (!ADS_ERR_OK(status)) {
1791
DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status)));
1792
nt_status = ads_ntstatus(status);
1796
if (strcmp(ads->config.realm, lp_realm()) != 0) {
1797
d_fprintf(stderr, "realm of remote server (%s) and realm in %s "
1798
"(%s) DO NOT match. Aborting join\n",
1799
ads->config.realm, get_dyn_CONFIGFILE(), lp_realm());
1800
nt_status = NT_STATUS_INVALID_PARAMETER;
1804
if (!(ctx = talloc_init("net_ads_join"))) {
1805
d_fprintf(stderr, "Could not initialise talloc context.\n");
1806
nt_status = NT_STATUS_NO_MEMORY;
1803
1810
/* If we were given an OU, try to create the machine in
1804
1811
the OU account first and then do the normal RPC join */