home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2509 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.9 KB  |  54 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32net
  5. import win32security
  6. import win32api
  7. import win32con
  8. import win32profile
  9. import win32cred
  10. uiinfo = {
  11.     'MessageText': 'Enter credentials for local machine',
  12.     'CaptionText': 'win32cred_demo.py' }
  13. (target, pwd, save) = win32cred.CredUIPromptForCredentials(TargetName = win32api.GetComputerName(), AuthError = 0, Flags = win32cred.CREDUI_FLAGS_DO_NOT_PERSIST | win32cred.CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX, Save = False, UiInfo = uiinfo)
  14. attrs = [
  15.     {
  16.         'Keyword': 'attr1',
  17.         'Flags': 0,
  18.         'Value': u'unicode data' },
  19.     {
  20.         'Keyword': 'attr2',
  21.         'Flags': 0,
  22.         'Value': 'character data' }]
  23. cred = {
  24.     'Comment': 'Created by win32cred_demo.py',
  25.     'UserName': target,
  26.     'TargetAlias': None,
  27.     'TargetName': target,
  28.     'CredentialBlob': pwd,
  29.     'Flags': win32cred.CRED_FLAGS_USERNAME_TARGET,
  30.     'Persist': win32cred.CRED_PERSIST_ENTERPRISE,
  31.     'Type': win32cred.CRED_TYPE_DOMAIN_PASSWORD,
  32.     'Attributes': attrs }
  33. win32cred.CredWrite(cred)
  34. pwd = None
  35. print win32cred.CredRead(target, win32cred.CRED_TYPE_DOMAIN_PASSWORD)
  36. mc = win32cred.CredMarshalCredential(win32cred.UsernameTargetCredential, target)
  37. th = win32security.LogonUser(mc, None, '', win32con.LOGON32_LOGON_INTERACTIVE, win32con.LOGON32_PROVIDER_DEFAULT)
  38. win32security.ImpersonateLoggedOnUser(th)
  39. print 'GetUserName:', win32api.GetUserName()
  40. win32security.RevertToSelf()
  41. (username, domain) = win32cred.CredUIParseUserName(target)
  42. user_info_4 = win32net.NetUserGetInfo(None, username, 4)
  43. profilepath = user_info_4['profile']
  44. if not profilepath:
  45.     profilepath = None
  46.  
  47. hk = win32profile.LoadUserProfile(th, {
  48.     'UserName': username,
  49.     'Flags': 0,
  50.     'ProfilePath': profilepath })
  51. env = win32profile.CreateEnvironmentBlock(th, False)
  52. win32profile.UnloadUserProfile(th, hk)
  53. th.Close()
  54.