public bool CheckAccess()

in CustomSecuritySample/Authorization.cs [162:197]


      public bool CheckAccess(
         string userName, 
         IntPtr userToken, 
         byte[] secDesc, 
         CatalogOperation requiredOperation)
      {
         // 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(CatalogOperation aclOperation in ace.CatalogOperations)
               {
                  if (aclOperation == requiredOperation)
                     return true;
               }
            }
         }
         
         return false;
      }