in CustomSecuritySample2016/Authorization.cs [74:109]
public bool CheckAccess(
string userName,
IntPtr userToken,
byte[] secDesc,
ModelItemOperation modelItemOperation)
{
// If the user is the administrator, allow unrestricted access.
// Because SQL Server defaults to case-insensitive, we have to
// perform a case insensitive comparison. Ideally you would check
// the SQL Server instance CaseSensitivity property before making
// a case-insensitive comparison.
if (0 == String.Compare(userName, m_adminUserName, true,
CultureInfo.CurrentCulture))
return true;
AceCollection acl = DeserializeAcl(secDesc);
foreach (AceStruct ace in acl)
{
// First check to see if the user or group has an access control
// entry for the item
if (0 == String.Compare(userName, ace.PrincipalName, true,
CultureInfo.CurrentCulture))
{
// If an entry is found,
// return true if the given required operation
// is contained in the ACE structure
foreach (ModelItemOperation aclOperation in ace.ModelItemOperations)
{
if (aclOperation == modelItemOperation)
return true;
}
}
}
return false;
}