1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Retrieve SID both on DC and on client

This commit is contained in:
Игорь Чудов 2019-11-15 16:36:15 +04:00
parent 8e6da8a16a
commit 58d864ff70
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -45,6 +45,10 @@ import control
import socket
import subprocess
# Facility to get SID from username
import pysss_nss_idmap
class tdb_regedit:
'''
regedit object for samba-regedit which has separate registry and
@ -352,9 +356,18 @@ def wbinfo_getsid(domain, user):
'''
Get SID using wbinfo
'''
wbinfo_cmd = ['wbinfo', '-n', '{}\\{}'.format(domain.upper(), user)]
# This part works only on client
username = '{}\\{}'.format(domain.upper(), user)
sid = pysss_nss_idmap.getsidbyname(username)
if username in sid:
return sid[username]['sid']
# This part works only on DC
wbinfo_cmd = ['wbinfo', '-n', username]
output = subprocess.check_output(wbinfo_cmd)
sid = output.split()[0].decode('utf-8')
return sid
def machine_kinit():