NTFS and share permissions on a folder

T

Thierry Kennes

Hello,

I'm trying to get the permissions on a shared folder using
NetShareGetInfo api.
I've got this function above that is supposed to give me the
permission thanks to shi2_permission.
The thing is that it always return '0' whether the permission is set
with "Read" or both "Read/Change" (Full control).
So can anyone explain to me what does that mean ? or let me know if
there is a problem with this function.

Thanks in advance.


static string NetShareGetPermission(string serverName, string
netName)
{
string permission = null;
IntPtr ptr = IntPtr.Zero;
int level = 2;

int errCode = NetShareGetInfo(serverName, netName, level,
ref ptr);

if (errCode == NERR_Success)
{
SHARE_INFO_2 shareInfo = (SHARE_INFO_2)
Marshal.PtrToStructure(ptr, typeof(SHARE_INFO_2));

permission = shareInfo.shi2_permissions.ToString();
Console.WriteLine("Path : \t\t" +
shareInfo.shi2_path.ToString());
Console.WriteLine("Max Users : \t" +
shareInfo.shi2_max_uses.ToString());
Console.WriteLine("Description : \t" +
shareInfo.shi2_remark.ToString());
NetApiBufferFree(ptr);
}
else
{
Console.WriteLine(FormatMessage(errCode));
return "Error";
}
return permission;
}
 
T

Thierry Kennes

That's not a .NET function, so your question is very much off-topic here.

That said, the field you are looking at applies only if the share is  
configured with share-level permissions.  These days, it's very unusual to  
see that; usually permissions are set with user-level permissions.  So  
maybe you're simply not looking at the right information?

In any case, there's really nothing about your question that pertains to  
.NET, never mind C#.  For a really good answer, you'll probably want to  
find a more appropriate newsgroup.

Pete

Thanks anyway. I actually need this information even though it's
unusual :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top