win32net.NetUserGetInfo

Here are the examples of the python api win32net.NetUserGetInfo taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

Example 1

Project: WAPT
Source File: win32netdemo.py
View license
def GetInfo(userName=None):
    "Dumps level 3 information about the current user"
    if userName is None: userName=win32api.GetUserName()
    print "Dumping level 3 information about user"
    info = win32net.NetUserGetInfo(server, userName, 3)
    for key, val in info.items():
        verbose("%s=%s" % (key,val))

Example 2

Project: WAPT
Source File: win32netdemo.py
View license
def SetInfo(userName=None):
    "Attempts to change the current users comment, then set it back"
    if userName is None: userName=win32api.GetUserName()
    oldData = win32net.NetUserGetInfo(server, userName, 3)
    try:
        d = oldData.copy()
        d["usr_comment"] = "Test comment"
        win32net.NetUserSetInfo(server, userName, 3, d)
        new = win32net.NetUserGetInfo(server, userName, 3)['usr_comment']
        if  str(new) != "Test comment":
            raise RuntimeError("Could not read the same comment back - got %s" % new)
        print "Changed the data for the user"
    finally:
        win32net.NetUserSetInfo(server, userName, 3, oldData)

Example 3

Project: TrustRouter
Source File: win32netdemo.py
View license
def GetInfo(userName=None):
    "Dumps level 3 information about the current user"
    if userName is None: userName=win32api.GetUserName()
    print("Dumping level 3 information about user")
    info = win32net.NetUserGetInfo(server, userName, 3)
    for key, val in list(info.items()):
        verbose("%s=%s" % (key,val))

Example 4

Project: TrustRouter
Source File: win32netdemo.py
View license
def SetInfo(userName=None):
    "Attempts to change the current users comment, then set it back"
    if userName is None: userName=win32api.GetUserName()
    oldData = win32net.NetUserGetInfo(server, userName, 3)
    try:
        d = oldData.copy()
        d["usr_comment"] = "Test comment"
        win32net.NetUserSetInfo(server, userName, 3, d)
        new = win32net.NetUserGetInfo(server, userName, 3)['usr_comment']
        if  str(new) != "Test comment":
            raise RuntimeError("Could not read the same comment back - got %s" % new)
        print("Changed the data for the user")
    finally:
        win32net.NetUserSetInfo(server, userName, 3, oldData)

Example 5

Project: minos
Source File: winFTPserver.py
View license
    def authorize (self, channel, userName, passWord):
        self.AdjustPrivilege( ntsecuritycon.SE_CHANGE_NOTIFY_NAME )
        self.AdjustPrivilege( ntsecuritycon.SE_ASSIGNPRIMARYTOKEN_NAME )
        self.AdjustPrivilege( ntsecuritycon.SE_TCB_NAME )
        try:
            logonHandle = win32security.LogonUser( userName,
                                                   None,
                                                   passWord,
                                                    win32con.LOGON32_LOGON_INTERACTIVE,
                                                    win32con.LOGON32_PROVIDER_DEFAULT )
        except pywintypes.error, ErrorMsg:
            return 0, ErrorMsg[ 2 ], None

        userInfo = win32net.NetUserGetInfo( None, userName, 1 )

        return 1, 'Login successful', filesys.os_filesystem( userInfo[ 'home_dir' ] )

Example 6

Project: seafdav
Source File: nt_domain_controller.py
View license
    def getRealmUserPassword(self, realmname, username, environ):
        (domain, user) = self._getDomainUsername(username)
        dcname = self._getDomainControllerName(domain)
        
        try: 
            userdata = win32net.NetUserGetInfo(dcname, user, 1)
        except:
            _logger.exception("NetUserGetInfo")
            userdata = {}
#        if "password" in userdata:
#            if userdata["password"] != None:
#                return userdata["password"]
#        return None
        return userdata.get("password")

Example 7

Project: wsgidav
Source File: nt_domain_controller.py
View license
    def getRealmUserPassword(self, realmname, username, environ):
        (domain, user) = self._getDomainUsername(username)
        dcname = self._getDomainControllerName(domain)

        try:
            userdata = win32net.NetUserGetInfo(dcname, user, 1)
        except:
            _logger.exception("NetUserGetInfo")
            userdata = {}
#        if "password" in userdata:
#            if userdata["password"] != None:
#                return userdata["password"]
#        return None
        return userdata.get("password")

Example 8

Project: wsgidav
Source File: nt_domain_controller.py
View license
    def getRealmUserPassword(self, realmname, username, environ):
        (domain, user) = self._getDomainUsername(username)
        dcname = self._getDomainControllerName(domain)

        try:
            userdata = win32net.NetUserGetInfo(dcname, user, 1)
        except:
            _logger.exception("NetUserGetInfo")
            userdata = {}
#        if "password" in userdata:
#            if userdata["password"] != None:
#                return userdata["password"]
#        return None
        return userdata.get("password")

Example 9

Project: cloudbase-init
Source File: windows.py
View license
    def _get_user_info(self, username, level):
        try:
            return win32net.NetUserGetInfo(None, username, level)
        except win32net.error as ex:
            if ex.args[0] == self.NERR_UserNotFound:
                raise exception.ItemNotFoundException(
                    "User not found: %s" % username)
            else:
                raise exception.CloudbaseInitException(
                    "Failed to get user info: %s" % ex.args[2])