Skip to content

Instantly share code, notes, and snippets.

@v2m
Last active December 17, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v2m/5543629 to your computer and use it in GitHub Desktop.
Save v2m/5543629 to your computer and use it in GitHub Desktop.
// add reference to System.DirectoryServices.AccountManagement.dll
var sidAttr = pool.Attributes["applicationPoolSid"];
var securityIdentifier = new SecurityIdentifier((string)sidAttr.Value);
using(var ctx = new PrincipalContext(ContextType.Machine))
using(var group = GroupPrincipal.FindByIdentity(ctx, IdentityType.Sid, (string)securityIdentifier.Value))
{
Debug.Assert(group != null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment