title: Enumerate shared folders on Windows with low privileges
body: <p>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.</p>
  
  <p>We've been using <a href="http://msdn.microsoft.com/en-us/library/bb525387(VS.85).aspx" rel="nofollow noreferrer"><code>NetShareEnum</code></a> for this fairly successfully, but have hit a problem where we need to run with a user account with low privileges.</p>
  
  <p>To get the local path using <code>NetShareEnum</code> we need to retrieve at least <a href="http://msdn.microsoft.com/en-us/library/bb525410(v=VS.85).aspx" rel="nofollow noreferrer"><code>SHARE_INFO_2</code></a> structures - but that requires "<em>Administrator, Power User, Print Operator, or Server Operator group membership</em>".</p>
  
  <p>I've been trying to use <a href="http://msdn.microsoft.com/en-us/library/aa385478(v=VS.85).aspx" rel="nofollow noreferrer"><code>WNetOpenEnum</code></a> and <a href="http://msdn.microsoft.com/en-us/library/aa385449(VS.85).aspx" rel="nofollow noreferrer"><code>WNetEnumResource</code></a> instead but I don't seem to be getting the local name back for that for shares either. AFAICS it only enumerates the shares from an external perspective.</p>
  
  <p>So I'd either like help on where I'm going wrong with <code>WNetEnumResource</code>, or a suggestion as to another way of doing this. Any suggestions are much appreciated.</p>