當前位置: 首頁>>代碼示例>>Python>>正文


Python win32net.NetUserEnum方法代碼示例

本文整理匯總了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" 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:16,代碼來源:win32netdemo.py

示例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]] 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:8,代碼來源:authorizers.py

示例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 
開發者ID:cloudbase,項目名稱:cloudbase-init,代碼行數:16,代碼來源:windows.py

示例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 
開發者ID:lightfaith,項目名稱:locasploit,代碼行數:45,代碼來源:windows_enumeration_users.py


注:本文中的win32net.NetUserEnum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。