]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool user: use remote domain information
authorBjörn Baumbach <bb@sernet.de>
Tue, 19 Jan 2021 09:53:48 +0000 (10:53 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 1 Mar 2021 03:50:35 +0000 (03:50 +0000)
Required, when running get_account_attributes() against a remote samdb.

avoid:
ERROR(<class 'AttributeError'>): uncaught exception - 'NoneType' object has no attribute 'get'
  File "bin/python/samba/netcmd/__init__.py", line 186, in _run
    return self.run(*args, **kwargs)
  File "bin/python/samba/netcmd/user.py", line 2769, in run
    obj = self.get_account_attributes(samdb, username,
  File "bin/python/samba/netcmd/user.py", line 1250, in get_account_attributes
    realm = self.lp.get("realm")

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/user.py

index 8ffff09a35ef0e6fe31bbc5fd39f5275cc798f95..8ba5168c04955c4643ac3b12544b7fc0091f6375 100644 (file)
@@ -1232,7 +1232,7 @@ class GetPasswordCommand(Command):
         if "userPrincipalName" in obj:
             account_upn = str(obj["userPrincipalName"][0])
         else:
-            realm = self.lp.get("realm")
+            realm = samdb.domain_dns_name()
             account_upn = "%s@%s" % (account_name, realm.lower())
         if add_userPrincipalName:
             del obj["userPrincipalName"]
@@ -1544,7 +1544,7 @@ class GetPasswordCommand(Command):
                     i = int(x)
                 except ValueError:
                     continue
-                domain = self.lp.get("workgroup")
+                domain = samdb.domain_netbios_name()
                 dns_domain = samdb.domain_dns_name()
                 v = get_wDigest(i, primary_wdigest, account_name, account_upn, domain, dns_domain)
                 if v is None: