title: How to determine the effective permissions for a user of a SQL Server database through C#?
body: <p>When I say effective permissions, I'm referring to the permissions listed when you go into the properties of a database in SQL Server Management Studio, click "Permissions", and then click the "Effective" tab.</p>
  
  <p>So far, I have been able to determine the explicit permissions with the following code:</p>
  
  <pre><code>using Microsoft.SqlServer.Management.Smo;
  ...
  DatabasePermissionInfo[] permissions = database.EnumDatabasePermissions("username");
  </code></pre>
  
  <p>However, I still need to obtain the effective permissions. In this scenario, I added a login for a user and gave it the role of <code>db_datareader</code> and <code>db_datawriter</code> for a database through the User Mapping.  </p>
  
  <p>In the permissions for the database, the effective permissions listed are <code>CONNECT, DELETE, INSERT, SELECT,</code> and <code>UPDATE</code>, but the explicit permissions only list connect (which is the only thing that the above code pulls back). So is there a way to programmatically retrieve the effective permissions as well?  </p>
  
  <p>Thanks.</p>