I am trying to check Read permission for the current user on a specific item like the following:
Sitecore.Data.Database.GetDatabase("master")
.SelectItems("/sitecore/content/Settings/Item1")[0]
.Security.CanRead(Sitecore.Context.User)
This always returns true even though the 'Access Viewer' shows revoked 'Read' permission for the same user.
The revoking has been done using Roles.
What is wrong with this code?
UPDATE:
This code is being run from publish:begin event. The Sitecore.Context.User does have the required (logged-in) user. I see this on the AccessViewer (I have edited the code to CanWrite()): But both options mentioned in the answers always return True.