[PATCH] Joining domains specifying auth realm

Ken Cross kcross at nssolutions.com
Fri Mar 14 16:01:02 GMT 2003


Let's try this again.  The previous patch I submitted didn't work in
some configurations.  (ads->auth.realm needs to be preserved over the
ads_connect call.)

This patch is for SAMBA_3_0.

Ken
________________________________

Ken Cross

Network Storage Solutions
Phone 865.675.4070 ext 31
kcross at nssolutions.com 



RCS file: /cvsroot/samba/source/utils/net_ads.c,v
retrieving revision 1.37.2.12
diff -p -u -r1.37.2.12 net_ads.c
--- utils/net_ads.c     24 Feb 2003 03:06:45 -0000      1.37.2.12
+++ utils/net_ads.c     14 Mar 2003 15:55:45 -0000
@@ -122,6 +125,7 @@ static ADS_STRUCT *ads_startup(void)
        ADS_STATUS status;
        BOOL need_password = False;
        BOOL second_time = False;
+       char *cp, *realm_save = NULL;
        
        ads = ads_init(NULL, NULL, opt_host);
 
@@ -147,7 +151,29 @@ retry:
 
        ads->auth.user_name = strdup(opt_user_name);
 
+       /*
+        * If the username is of the form "name at realm", 
+        * extract the realm and convert to upper case.
+        * This is only used to establish the connection.
+        */
+       realm_save = ads->auth.realm;
+       if (cp = strchr(ads->auth.user_name, '@')) {
+               *cp++ = '\0';
+               ads->auth.realm = cp;
+               strupper(ads->auth.realm);
+       }
+
        status = ads_connect(ads);
+
+       /*
+        * Restore the realm name.  If there wasn't one,
+        * default to the configuration realm.
+        */
+       if( realm_save == NULL )
+               realm_save = strdup(ads->config.realm);
+
+       ads->auth.realm = realm_save;
+
        if (!ADS_ERR_OK(status)) {
                if (!need_password && !second_time) {
                        need_password = True;



More information about the samba-technical mailing list