骨のダイスを転がそう

2009|01|02|03|04|05|06|07|10|12|
2010|01|02|03|04|05|06|07|08|09|10|11|
2011|02|03|05|06|07|08|09|10|11|12|
2012|01|02|04|05|09|10|11|12|
2013|01|02|04|
2014|11|
2015|01|04|05|
2016|06|07|08|09|11|
2017|01|02|03|04|
2018|03|

2010-11-08

_ [.Net] ADに接続して、グループの所属を確認

System.DirectoryServices.AccountManagement を参照に加えておいて、using で名前空間をインポート。

           using (
               PrincipalContext ctx = new PrincipalContext(
               ContextType.Domain,
               "HOGE",
               "OU=FUGA,DC=hoge,DC=or,DC=jp",
               "hogehoge",
               "fugafuga")
               )
           {
               GroupPrincipal g = GroupPrincipal.FindByIdentity(ctx, "admins");

               UserPrincipal u = UserPrincipal.FindByIdentity(ctx, @"HOGE\foobar");

               if (g != null)
               {
                   Console.WriteLine(u.IsMemberOf(g).ToString());

                   foreach (var n in g.Members)
                   {
                       Console.WriteLine(n.DisplayName);
                   }
               }
               else
               {
                   Console.WriteLine("グループが見付かりませんでした。");
               }
           }