siddhartha veedaluru wrote:
>  
> I'm trying to connect to a remote windows machine's registry using
> ConnectRegistry and try to get the process architecture information.
>   
> Here is the code snippet for it
> #processRegKey = "System\CurrentControlSet\Control\Session
> Manager\Environment"
> #processRegValue = "PROCESSOR_ARCHITECTURE"
> #try:
> #    regHandle = ConnectRegistry(r"\\atom",HKEY_LOCAL_MACHINE
> <file://atom%22,hkey_local_machine/>)
> #    regHandleObj =  OpenKey(regHandle, processRegKey)
> #    processType =  QueryValueEx(regHandleObj,
> processRegValue)[0].split(" ")[0]
> #    print processType
> #except Exception, erno:
> #    print "Exception:"
> #    print erno
>  
> but it fails with access denied errors.
> I assume that there is credentials issue.
> but i have the credential, but where should i have to provide this.

If the user you are currently logged in as is valid on the other
machine, this should just work.

Otherwise, you will have to call win32security.LogonUser and
win32security.ImpersonateLoggedOnUser before calling ConnectRegistry.

    handle = win32Security.LogonUser( 'username', 'domain', 'password',
        win32con.LOGON32_LOGON_INTERACTIVE,
        win32con.LOGON32_PROVIDER_DEFAULT )
    win32security.ImpersonateLoggonOnUser( handle )
   
    # ... connect to to registry here ...

    win32security.RevertToSelf()
    handle.Close()

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to