Finding User Profile path

kyosohma at gmail.com kyosohma at gmail.com
Thu Mar 29 18:07:59 CEST 2007


On Mar 29, 10:30 am, Tim Golden <m... at timgolden.me.uk> wrote:
> [resending as the original seems to have got lost;
> apologies if it appears as a duplicate]
>
> At the risk of insulting your intelligence, here's a
> rough-and-ready non-AD solution (culled from some code I
> had somewhere):
>
> <code>
> import win32net
> import win32netcon
>
> dc = win32net.NetGetAnyDCName (None, None)
> #
> # Or your specific server name, if you want
> #
>
> resume = 0
> while 1:
>    (_users, total, resume) = \
>      win32net.NetUserEnum (
>        dc,
>        3,
>        win32netcon.FILTER_NORMAL_ACCOUNT,
>        resume,
>        win32netcon.MAX_PREFERRED_LENGTH
>      )
>    for _user in _users:
>      print _user['name'], _user['home_dir'], _user['profile']
>    if not resume:
>      break
>
> </code>
>
> TJG

Thanks a lot. That seems to work the way we need. And don't worry too
much about my intelligence...I've only been programming in Python
since last May.

Mike




More information about the Python-list mailing list