--- samba-3.0.2a/source/libads/ldap.c.orig 2004-04-28 10:51:18.000000000 +0200 +++ samba-3.0.2a/source/libads/ldap.c 2004-04-28 14:20:26.000000000 +0200 @@ -190,8 +190,10 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads) { int version = LDAP_VERSION3; + int ismachine = 0; ADS_STATUS status; +repeat: ads->last_attempt = time(NULL); ads->ld = NULL; @@ -227,11 +229,17 @@ if (!ads->auth.user_name) { /* by default use the machine account */ + ismachine++; fstring myname; fstrcpy(myname, global_myname()); strlower_m(myname); asprintf(&ads->auth.user_name, "HOST/%s", myname); } + else if (ismachine) { + ismachine++; + memmove(ads->auth.user_name,ads->auth.user_name+5, + strlen(ads->auth.user_name)-4); + } if (!ads->auth.realm) { ads->auth.realm = strdup(ads->config.realm); @@ -264,7 +272,15 @@ return ADS_ERROR(ldap_simple_bind_s( ads->ld, ads->auth.user_name, ads->auth.password)); } - return ads_sasl_bind(ads); + status = ads_sasl_bind(ads); + + if (!ADS_ERR_OK(status)&&ismachine==1) + { + if (ads->ld) ldap_unbind(ads->ld); + goto repeat; + } + + return status; } /*