[python-win32] Finding users home directories

James Matthews nytrokiss at gmail.com
Sun Jan 13 11:42:31 CET 2008


I guess that would help! :)

On Jan 12, 2008 11:50 PM, Guilherme Polo <ggpolo at gmail.com> wrote:
>
> 2008/1/12, Giampaolo Rodola' <billiejoex at gmail.com>:
> > 2008/1/12, Guilherme Polo <ggpolo at gmail.com>:
> > > 2008/1/12, Giampaolo Rodola' <billiejoex at gmail.com>:
> > > > 2008/1/12, Giampaolo Rodola' <billiejoex at gmail.com>:
> > > > > 2008/1/12, Guilherme Polo <ggpolo at gmail.com>:
> > > > > > 2008/1/12, Giampaolo Rodola' <billiejoex at gmail.com>:
> > > > > > > Hi,
> > > > > > > I'm trying to use the pywin32 extension to find out the users home directories.
> > > > > > > Currently I found a way for doing that but it requires to validate the
> > > > > > > user by providing its username + password:
> > > > > > >
> > > > > > > def get_homedir(username, password):
> > > > > > >    token = win32security.LogonUser(
> > > > > > >        username,
> > > > > > >        None,
> > > > > > >        password,
> > > > > > >        win32security.LOGON32_LOGON_NETWORK,
> > > > > > >        win32security.LOGON32_PROVIDER_DEFAULT
> > > > > > >        )
> > > > > > >    return win32profile.GetUserProfileDirectory(token)
> > > > > > >
> > > > > > >
> > > > > > > What I'd like to do is avoiding the requirement of the password, in
> > > > > > > the same way as if I would on UNIX where it would be enough just using
> > > > > > > the pwd module and providing the username only:
> > > > > > >
> > > > > > >  >>> import pwd
> > > > > > >  >>> pwd.getpwnam('user').pw_dir
> > > > > > >  '/home/user'
> > > > > > >
> > > > > > > Does someone know if it is possible to do that?
> > > > > >
> > > > > > Did you try:
> > > > > >
> > > > > > import os
> > > > > > os.path.expanduser('~user')
> > > > >
> > > >
> > > > It doesn't seem to be what I'm searching for:
> > > >
> > > >  >>> os.path.expanduser('~')
> > > >  'C:\\Documents and Settings\\billiejoex'
> > > >  >>> os.path.expanduser('~user')
> > > >  '~user'
> > > >  >>>
> > >
> > > Does user 'user' actually exists ?
> >
> > Yes.
> > Look also those ones:
> >
> > >>> os.path.expanduser('~Administrator')
> > '~Administrator'
> > >>> os.path.expanduser('~Guest')
> > '~Guest'
> > >>>
> >
>
> Uhm.. my bad then, I should use windows before posting on pywin32.
>
> --
> -- Guilherme H. Polo Goncalves
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com


More information about the python-win32 mailing list