For a select group of users, list the depots each has permission to access based on their group memberships and ACL's. Built-in types anyuser and authuser are unsupported.
- See also
- AcDepots.canViewAsync, AcUser.initFromADAsync
- ShowPermissions.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="activeDir" type="AcUtils.ADSection, AcUtils, Version=1.6.4.0, Culture=neutral, PublicKeyToken=26470c2daf5c2e2f, processorArchitecture=MSIL" />
</configSections>
<activeDir>
<domains>
<!-- contact your company LDAP administrator for these values -->
<add host="xyzdc.mycorp.com" path="DC=XYZ,DC=xy,DC=zcorp,DC=com"/>
<add host="abcdc.mycorp.com" path="DC=ABC,DC=ab,DC=com"/>
</domains>
<properties>
</properties >
</activeDir>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
using System.Collections.Generic;
namespace ShowPermissions
{
class Program
{
private static DomainCollection _domains;
static int Main()
{
bool ret = false;
ADSection adSection = ConfigurationManager.GetSection("activeDir") as ADSection;
if (adSection == null)
Console.WriteLine("Error creating ADSection");
else
{
_domains = adSection.Domains;
Task<bool> pini = permissionsAsync();
ret = pini.Result;
}
return (ret) ? 0 : 1;
}
public static async Task<bool> permissionsAsync()
{
AcDepots depots = new AcDepots(dynamicOnly: true);
Task<bool> dini = depots.initAsync();
AcUsers users = new AcUsers(_domains, null, includeGroupsList: true);
Task<bool> uini = users.initAsync();
bool[] lists = await Task.WhenAll(dini, uini);
if (lists == null || lists.Any(n => n == false)) return false;
var arr = new[] { "thomas", "barnyrd", "madhuri", "robert" };
IEnumerable<AcUser> filter = users.Where(n => arr.Any(
user => n.Principal.Name ==
user));
foreach (AcUser
user in filter.OrderBy(n => n))
{
string availDepots = await depots.canViewAsync(user);
if (!String.IsNullOrEmpty(availDepots))
Console.WriteLine($"{user}{Environment.NewLine}{availDepots}{Environment.NewLine}");
}
return true;
}
}
}