[python-win32] Symbolic links/junctions in windows

Roger Upole rwupole at msn.com
Wed Oct 25 09:11:21 CEST 2006


"Marc Dubrowski" <marc.dubrowski at gmail.com> wrote in message news:6bcf9d700610230417v1361b397k90f7a05007f8862 at mail.gmail.com...
> Hi Mark, thanks for your answer.
>
> I'm afraid I have not been clear enough in the the description of what I
> want to do: i want symbolic links, also called junctions by microsoft.
>
> For the moment, the management of properties on files and folders is
> disastrous: some users can more less do what they want about this. This
> creates lots of problems and confusion. For example, if someone  moves from
> a department to another one, he should no longer be authorized to read/write
> the documents in the folder of the former department.  As the permissions
> are granted to users instead of groups, It is far than trivial to find out
> on which folders  the authorizations should be removed/changed
>
> We need to change this and teach the users how to work with more discipline,
> but not too much: they don't all realize really what a server is. (It is not
> unusual for them to copy a file locally on different PCs, and still thinking
> they are working on the same document)
>
> My idea is as follow: every user will have 2 network drive: P: (for public
> data) and U: (for users data).
> In the U: drive, there will be the 'my document' folder. Physically, it will
> be on one drive of the file server. With quotas on.
> Beside the 'my document' folder, there will be as many folders as groups the
> user is member of.
> Practically, these folders will be on another drive of the server: one per
> group. What I want is to create a symbolic link on the server: from
> h:\group_folder to u:\%username%\group_folder for all the groups the user is
> member of.
>
> The advantage is that the h: drive on the server would not be visible on the
> network.
>
> Windows shell links, as far as I have understood, creates link files
> (*.lnk). It wouldn't work and would oblige me to share the h: drive's
> content, which I don not want.
>
> A batch file would use linkd.exe from the w2k3 resource kit, or
> junction.exefrom sysinternals.
>
> But I guess it would be better for my scripts (create_user, modify_users,
> delete_users) if they could just call the win32 api instead of using
> os.popen().
>
> Is there a way to accomplish this ?
>

You can use win32file.DeviceIoControl to create junctions (also known as
reparse points).   See this post for some code to do so:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/939a0d8d54200693/a2002a03f59afbea?lnk=gst&q=DeviceIoControl&rnum=5#a2002a03f59afbea

However, from the description it sounds like DFS might suit
your needs better.

            Roger




More information about the Python-win32 mailing list