本文整理汇总了Python中win32net.NetUserEnum方法的典型用法代码示例。如果您正苦于以下问题:Python win32net.NetUserEnum方法的具体用法?Python win32net.NetUserEnum怎么用?Python win32net.NetUserEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32net
的用法示例。
在下文中一共展示了win32net.NetUserEnum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserEnum
# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def UserEnum():
"Enumerates all the local users"
resume = 0
nuser = 0
while 1:
data, total, resume = win32net.NetUserEnum(server, 3, win32netcon.FILTER_NORMAL_ACCOUNT, resume)
verbose("Call to NetUserEnum obtained %d entries of %d total" % (len(data), total))
for user in data:
verbose("Found user %s" % user['name'])
nuser = nuser + 1
if not resume:
break
assert nuser, "Could not find any users!"
print "Enumerated all the local users"
示例2: _get_system_users
# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def _get_system_users(cls):
"""Return all users defined on the Windows system."""
# XXX - Does Windows allow usernames with chars outside of
# ASCII set? In that case we need to convert this to unicode.
return [entry['name'] for entry in
win32net.NetUserEnum(None, 0)[0]]
示例3: enum_users
# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def enum_users(self):
usernames = []
resume_handle = 0
while True:
try:
users_info, total, resume_handle = win32net.NetUserEnum(
None, 0, win32netcon.FILTER_NORMAL_ACCOUNT, resume_handle)
except win32net.error as ex:
raise exception.CloudbaseInitException(
"Enumerating users failed: %s" % ex.args[2])
usernames += [u["name"] for u in users_info]
if not resume_handle:
return usernames
示例4: run
# 需要导入模块: import win32net [as 别名]
# 或者: from win32net import NetUserEnum [as 别名]
def run(self):
silent = positive(self.parameters['SILENT'].value)
activeroot = self.parameters['ACTIVEROOT'].value
import win32net
ip = get_address_from_active_root(activeroot)
if ip is None:
log.err('Cannot get proper address for active root.')
return None
# get all users
rh = 0
while True:
users = win32net.NetUserEnum(ip, 1, rh)
unixusers = [] # prepare list of unix-style values
for user in users[0]:
username = user['name']
uid = str(win32net.NetUserGetInfo(ip, username, 4)['user_sid'])[6:].split('-')[-1]
admin = is_admin(username, self.parameters['ACTIVEROOT'].value)
if not silent:
if admin:
log.ok('User %s - %s (Administrator)' % (uid, username))
else:
log.ok('User %s - %s' % (uid, username))
unixusers.append([username, None, uid, None, None, None, None, admin])
#db['analysis'].add_user(activeroot, uid, username, admin)
result = db['analysis'].add_users(activeroot, unixusers, USERS_UNIXLIKE)
if result == DB_ERROR:
log.err('Cannot insert users into DB.')
else:
if not silent:
log.ok('%d users added/updated.' % (len(unixusers)))
#groups = win32net.NetLocalGroupEnum(ip, 1)
#groups = win32net.NetUserGetLocalGroups(ip, username, 2)
# TODO how to get GID????
#for group in groups[0]:
# print(group)
# print(win32net.NetLocalGroupGetInfo(ip, group['name'], 1))
# insert ug
if rh == 0:
break
return None