﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Are you an administrator?</title><description>Phil,
The SamAccountName isn't really helping perf in any material way.
And the GetAuthorizationGroups() is used to get all groups in the hierarchy.</description><link>http://ayende.com/158401/are-you-an-administrator#comment4</link><guid>http://ayende.com/158401/are-you-an-administrator#comment4</guid><pubDate>Fri, 14 Sep 2012 07:47:06 GMT</pubDate></item><item><title>gunteman commented on Are you an administrator?</title><description>&lt;s&gt;whatever&lt;/s&gt; whether

Just sayin' ...
</description><link>http://ayende.com/158401/are-you-an-administrator#comment3</link><guid>http://ayende.com/158401/are-you-an-administrator#comment3</guid><pubDate>Wed, 12 Sep 2012 21:36:37 GMT</pubDate></item><item><title>njy commented on Are you an administrator?</title><description>i suppose your solution will have something to do with the current name of the method, "IsAdministratorNoCache" and in particular that "NO CACHE" part ;)</description><link>http://ayende.com/158401/are-you-an-administrator#comment2</link><guid>http://ayende.com/158401/are-you-an-administrator#comment2</guid><pubDate>Wed, 12 Sep 2012 12:59:46 GMT</pubDate></item><item><title>Phil Bolduc commented on Are you an administrator?</title><description>
You could help the API by telling it you are providing a SamAccountName.

var up = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, username);

Not really sure the difference between GetAuthorizationGroups and GetGroups, but, you could just call 

using (PrincipalSearchResult&lt;Principal&gt; groups = up.GetGroups())
{
  return groups.Any(principal =&gt;
                              principal.Sid.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid) ||
                              principal.Sid.IsWellKnown(WellKnownSidType.AccountDomainAdminsSid) ||
                              principal.Sid.IsWellKnown(WellKnownSidType.AccountAdministratorSid) ||
                              principal.Sid.IsWellKnown(WellKnownSidType.AccountEnterpriseAdminsSid));
}

Look forward to seeing your analysis of what took all the time, </description><link>http://ayende.com/158401/are-you-an-administrator#comment1</link><guid>http://ayende.com/158401/are-you-an-administrator#comment1</guid><pubDate>Wed, 12 Sep 2012 09:54:30 GMT</pubDate></item></channel></rss>