[python-win32] Finding users home directories
Guilherme Polo
ggpolo at gmail.com
Sat Jan 12 21:56:26 CET 2008
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')
?
>
> Thanks in advance
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
--
-- Guilherme H. Polo Goncalves
More information about the python-win32
mailing list