This web part will be inherited from Microsoft.SharePoint.WebPartPages.DataFormWebPart because i want to use XSLT transformation generated in sharepoint designer.



Method GetXPathNavigator will be overridded.

 

    public class GlobalPermissions :  Microsoft.SharePoint.WebPartPages.DataFormWebPart

    {

        System.Xml.XmlDocument xmlData = null;

        public GlobalPermissions()

        {

            this.ExportMode = System.Web.UI.WebControls.WebParts.WebPartExportMode.All;

        }

        protected override System.Xml.XPath.XPathNavigator GetXPathNavigator(string viewPath)

        {

            try

            {

                makeXMLGlobal();

                return xmlData.CreateNavigator();

            }

            catch (Exception e)

            {

                LogError(e);

                return base.GetXPathNavigator(viewPath);

            }

        }

    }

//And method which creating XML document with permissions will be added  

        private void makeXMLGlobal()

        {

            try

            {

                SPSecurity.RunWithElevatedPrivileges(delegate()

                {

                    ProjectInfo PI = new ProjectInfo(SPContext.Current.Site);

                    System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(PI.ConnectionStringPublished);

                    sqlConnection.Open();

                    string qry = queries.PermissionsNames.Replace("1033", SPContext.Current.Web.Language.ToString());

                    System.Data.DataSet ds = new DataSet("Permissions");

                    System.Data.DataTable tableNames = new DataTable("Names");

                    using (System.Data.SqlClient.SqlDataReader drPermissions = new System.Data.SqlClient.SqlCommand(qry, sqlConnection).ExecuteReader())

                    {

                        tableNames.Load(drPermissions);

                    }

                    ds.Tables.Add(tableNames);

                    System.Data.DataTable tableGlobal = new DataTable("Global");

                    using (System.Data.SqlClient.SqlDataReader drPermissions = new System.Data.SqlClient.SqlCommand(queries.GlobalPermissions , sqlConnection).ExecuteReader())

                    {

                        tableGlobal.Load(drPermissions);

                    }

                    ds.Tables.Add(tableGlobal);

                    xmlData = new XmlDocument();

                    xmlData.LoadXml(ds.GetXml());

                    ds.Dispose();

                   

                }

                );

            }

            catch (Exception e)

            {

                LogError(e);

            }

        }

        private void LogError(Exception ex)

        {

            System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();

            myLog.Source = "Web Part Permissions";

            myLog.WriteEntry(ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException, System.Diagnostics.EventLogEntryType.Error);

        }

SPD Customization.

 

When you insert this web part to web page, following Error message will be displayed.

At first we have to display XML document with user permissions

So Open web part properties and to  in XSL Editor copy  following Transformation.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xmp><xsl:copy-of select="*"/></xmp>

</xsl:template>

</xsl:stylesheet>

Now you can see xml document generated by function  makeXMLGlobal;

Select content of this web part, copy XML document to notepad and save it as XML document.

Start Sharepoint designer and open same Site(you can’t open PWA site)

Drag XML document to Folder List

 

In datasource Library, expand XML files and for uploaded XML document click to Show Data

As you can see XML containt 2 tables

Permission Names  are stored in table „Names“ , for each permission there is record with name, GUID and node name.

Global permission with resource information are stored in table „Global“

In table "Global" higlight Attributes n90102, n91006, RES_NAME and WRES_LAST_CONNECT_DATE and drag them to ASPX page.

Click to Edit Columns and change columns order.

Now change the date format click to litle "sign" next to the date value.

And change DateTime format

Now we should change the header names, Yust overwrite RES_NAME and WRES_LAST_CONNECT_DATE

by your text, for permission names I’m going to use names stored in xml

<xsl:value-of select="/Permissions/Names[ID='n90102']/CONV_STRING"></xsl:value-of>

<xsl:value-of select="/Permissions/Names[ID='n91006']/CONV_STRING"></xsl:value-of>

Now we wan to mark deleted resources.

So select the cell with resource name and replace  

<xsl:value-of select="RES_NAME"/>

      

With following code 

<xsl:element name="Font">

                     <xsl:attribute name="color">

                     <xsl:if test="RES_TYPE&gt;100">Red</xsl:if>

                     </xsl:attribute>

                           <xsl:value-of select="RES_NAME"/>

</xsl:element>

Copy XSL transformation, and Parameters generated by Sharepoint Designer (ins SPD display web part properties) to web part Autocont Project Global Permissions.

The seconx XSLT transformation display all global permissions.

I started teh same way as in previous case but, headers with permission names was replaced by

<xsl:for-each select="/Permissions/Names">

<th Style="border-style: solid;text-align: left ;

              border-width: 0px;

              display:block;

              writing-mode: tb-rl;

              filter: flipH() flipV();

"  nowrap="nowrap">

<xsl:value-of select="CONV_STRING"></xsl:value-of>

</th>               

</xsl:for-each>

This part display all permission names which are stored in XMLdocument.

In cell next to the resource name,  inserted following XSL framgment.

<xsl:variable name="mw" select="."/>

<xsl:for-each select="/Permissions/Names">

<td>

              <xsl:variable name="idperm" select="ID"/>             

               <xsl:if test="'1'=$mw/*[name()=$idperm]">

                      <img src="_layouts/IMAGES/portallink.gif"/>

              </xsl:if>

</td>

</xsl:for-each>

 

And there is a result: