Enumerate shared folders on Windows with low privileges

Posted by Phil Nash on Stack Overflow See other posts from Stack Overflow or by Phil Nash
Published on 2010-05-04T12:17:18Z Indexed on 2010/05/04 12:28 UTC
Read the original article Hit count: 473

Using C++ (VS2008) I need to be able to enumerate all shared folders on the current machine and get or construct the local and remote names.

We've been using NetShareEnum for this fairly successfully, but have hit a problem where we need to run with a user account with low privileges.

To get the local path using NetShareEnum we need to retrieve at least SHARE_INFO_2 structures - but that requires "Administrator, Power User, Print Operator, or Server Operator group membership".

I've been trying to use WNetOpenEnum and WNetEnumResource instead but I don't seem to be getting the local name back for that for shares either - and I can't seem to get it to enumerate just local resources - it goes off and finds all shared resources on the local network - which is not an acceptable overhead.

So I'd either like help on where I'm going wrong with WNetEnumResource, or a suggestion as to another way of doing this. Any suggestions are much appreciated.

© Stack Overflow or respective owner

Related posts about c++

Related posts about shared-folders