r6149: Fixes bugs #2498 and 2484.
[samba.git] / source / utils / net_ads.c
index 72e8f70a7d86e4e7639550f48d26072df911d7ca..34a357cd46d2f3c86b76866ef3174adf6cdd522b 100644 (file)
@@ -81,7 +81,7 @@ static int net_ads_lookup(int argc, const char **argv)
                d_printf("Didn't find the cldap server!\n");
                return -1;
        } if (!ads->config.realm) {
-               ads->config.realm = opt_target_workgroup;
+                ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
                ads->ldap_port = 389;
        }
 
@@ -94,7 +94,12 @@ static int net_ads_info(int argc, const char **argv)
 {
        ADS_STRUCT *ads;
 
-       ads = ads_init(NULL, opt_target_workgroup, opt_host);
+       /* if netbios is disabled we have to default to the realm from smb.conf */
+
+       if ( lp_disable_netbios() && *lp_realm() )
+               ads = ads_init(lp_realm(), opt_target_workgroup, opt_host);
+       else
+               ads = ads_init(NULL, opt_target_workgroup, opt_host);
 
        if (ads) {
                ads->auth.flags |= ADS_AUTH_NO_BIND;
@@ -1163,7 +1168,7 @@ static int net_ads_password(int argc, const char **argv)
        }
 
        if (argv[1]) {
-               new_password = (char *)argv[1];
+               new_password = CONST_DISCARD(char *, argv[1]);
        } else {
                asprintf(&prompt, "Enter new password for %s:", user);
                new_password = getpass(prompt);