<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        ' retrieve the AccessControl information for this file
        Dim sec As System.Security.AccessControl.FileSecurity
        sec = System.IO.File.GetAccessControl(Server.MapPath("TextFile.txt"))
        
        Me.Label1.Text = _
                 sec.GetOwner(GetType(System.Security.Principal.NTAccount)).Value
      
        ' retrieve the collection of access rules 
        Dim auth As System.Security.AccessControl.AuthorizationRuleCollection = _
                                     sec.GetAccessRules(true, true, _
                                     GetType(System.Security.Principal.NTAccount))

        Dim tc As TableCell
        ' loop through the rule collection and add a table row for each rule
        For Each r As System.Security.AccessControl.FileSystemAccessRule In auth
        
            Dim tr As New TableRow()
            
            tc = New TableCell()
            tc.Text = r.AccessControlType.ToString() ' deny or allow
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.IdentityReference.Value ' who
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.InheritanceFlags.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.IsInherited.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.PropagationFlags.ToString()
            tr.Cells.Add(tc)

            tc = New TableCell()
            tc.Text = r.FileSystemRights.ToString()
            tr.Cells.Add(tc)

            Table1.Rows.Add(tr)
        Next
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Displaying ACL Information</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p><b>File Owner:</b>
              <asp:Label ID="Label1" runat="server" Text="Label" /></p>        
        <p>
        Access Rules:<br />
        <asp:Table ID="Table1" runat="server" CellPadding="2" GridLines="Both">
            <asp:TableRow>
                <asp:TableHeaderCell>Control Type</asp:TableHeaderCell>
                <asp:TableHeaderCell>Identity</asp:TableHeaderCell>
                <asp:TableHeaderCell>Inheritance Flags</asp:TableHeaderCell>
                <asp:TableHeaderCell>Is Inherited</asp:TableHeaderCell>
                <asp:TableHeaderCell>Propagation Flags</asp:TableHeaderCell>     
                <asp:TableHeaderCell>File System Rights</asp:TableHeaderCell>
            </asp:TableRow>
        </asp:Table>
        </p>        
    </div>
    </form>
</body>
</html>
