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;
}