I currently have a database full of ACL entries which looks like so:
I need to go through and parse out the difference between a root node (like \\chrlcltsvr02\AYY_LMO\ClientServices) and it's child nodes (ex. \\chrlcltsvr02\AYY_LMO\ClientServices\Client1).
I've attempted doing this in C# code by using an ORM and raw T-SQL like so (I do in fact know that opening a session per row is a horrible idea):
foreach (string path in distinctPaths)
{
using (session = sessionFactory.OpenSession())
{
string query;
query = String.Format("SELECT DISTINCT UserGroup, AllowDeny, Permissions FROM FilerACLs WHERE FullPath LIKE '{0}'", path.Replace("'", "''"));
var parentACLs = session.CreateSQLQuery(query).SetResultTransformer(Transformers.AliasToBean<ShareACLEntry>()).List<ShareACLEntry>();
query = String.Format("SELECT DISTINCT UserGroup, AllowDeny, Permissions FROM FilerACLs WHERE FullPath LIKE '{0}\\%'", path.Replace("'", "''"));
var childACLs = session.CreateSQLQuery(query).SetResultTransformer(Transformers.AliasToBean<ShareACLEntry>()).List<ShareACLEntry>();
if (childACLs.Except(parentACLs, comparer).ToList().Count > 0)
Console.WriteLine("{0} has diffs!", path);
}
}
And finally comparing the resulting data to see whether the child nodes differ from the root node.
By differ, I mean if I have an ACL for group "CLT-AD\Full Access Shared-CHRL" with allowed full control on the parent node and not on the child node, I'd like to note that the ACL exists on the child but not the parent.
Unfortuantely, this process is far too slow to parse the 500k rows in any decent amount of time.
I'd like to know if anyone has an idea for efficiently determining if there is differences in the data--be it using T-SQL directly, a SQL CLR function, or a better algorithm in general.
Please let me know if clarification is required.
Thanks!
EDIT
Since I've gotten a fair amount of hate on this question let me re-clarify exactly what I'm looking for minus the failed approaches I've outlined above.
I recently performed a scan against ~1,000 shared folders on a Windows server. This scan recursed from the top level directory all the way down the hierarchy of folders, and for each folder recorded a row for each ACL.
The database therefore looks like the screenshot above.
What I need to do is pull a report from this database which details the difference (or even whether there is any) between the ACLs recorded from a top level directory and the ACLs recorded for any directory under this top level directory.
Hopefully that makes more sense.