Skip to content

Commit

Permalink
getuser may not work in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alxchk committed Apr 27, 2017
1 parent 798f266 commit 1b90075
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pupy/modules/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Users(PupyModule):
""" Get interactive users """

dependencies = {
'windows': ['win32net'],
'windows': ['win32net', 'win32api'],
'all': ['pupyutils.users']
}

Expand Down
9 changes: 4 additions & 5 deletions pupy/packages/all/pupyutils/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

if os.name == 'nt':
import win32net
import socket
import win32api

def users():
result = []
hostname = socket.gethostname()
users, _, _ = win32net.NetUserEnum(hostname, 1)
current = getpass.getuser()
users, _, _ = win32net.NetUserEnum(None, 1)
current = win32api.GetUserName()

UF_ACCOUNT_DISABLE = 2
UF_LOCKOUT = 16
Expand All @@ -20,7 +19,7 @@ def users():

result.append({
'name': user['name'],
'groups': win32net.NetUserGetLocalGroups(hostname, user['name']),
'groups': win32net.NetUserGetLocalGroups(None, user['name']),
'admin': user['priv'] == 2
})

Expand Down

0 comments on commit 1b90075

Please sign in to comment.