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:
parent
8e6da8a16a
commit
58d864ff70
15
gpoa/main.py
15
gpoa/main.py
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user