{"id":2320,"date":"2011-08-21T02:51:09","date_gmt":"2011-08-20T17:51:09","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/?p=2320"},"modified":"2011-08-21T02:51:09","modified_gmt":"2011-08-20T17:51:09","slug":"activedirecotry%e3%81%a7%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e3%81%8c%e3%81%a9%e3%81%ae%e3%82%b0%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ab%e5%b1%9e%e3%81%97%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.moonmile.net\/blog\/archives\/2320","title":{"rendered":"ActiveDirecotry\u3067\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u304c\u3069\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3057\u3066\u3044\u308b\u304b\u8abf\u3079\u308b"},"content":{"rendered":"<p>\u5b9f\u306f\u3001ActiveDirectry \u3092\u6271\u3046\u305f\u3081\u306b DirectoryEntry, DirectorySearch \u306a\u3093\u304b\u3092\u99c6\u4f7f\u3057\u306a\u3044\u3068\u99c4\u76ee\u306a\u306e\u304b\u306a\u3041\u3001\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u5358\u7d14\u306b\u73fe\u5728\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306b\u95a2\u3057\u3066\u306a\u3089\u3070\u3001\u30ed\u30fc\u30ab\u30eb\u306e Windows \u30e6\u30fc\u30b6\u30fc\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308c\u3070 OK \u3067\u3057\u305f\u3001\u3068\u3044\u3046\u30aa\u30c1\u3067\u3059\u3002<\/p>\n<p># ActiveDirecotry \u7279\u6709\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8abf\u3079\u308b\u5834\u5408\u306f\u3001DirectoryEntry \u306a\u3069\u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001 \u30ab\u30ec\u30f3\u30c8\u30e6\u30fc\u30b6\u30fc\u306e\u30b0\u30eb\u30fc\u30d7\u540d\u306e\u5217\u8a18\u3060\u3051\u306a\u3089\u3070\u3001\u7d50\u69cb\u7c21\u5358\u306b\u3001\u3068\u3044\u3046\u8a71\u3067\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u540d\u3084\u30c9\u30e1\u30a4\u30f3\u540d\u306f\u3001Environment \u306e\u30b9\u30bf\u30c6\u30a3\u30c3\u30af\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5229\u7528\u3057\u307e\u3059\u3002<br \/>\n\u30b0\u30eb\u30fc\u30d7\u540d\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u6642\u306f\u3001NTAccount \u30af\u30e9\u30b9\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3066\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u8a33\u3067\u7c21\u5358\u306b\u30bd\u30fc\u30b9\u3092\u3070\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nprivate void Form1_Load(object sender, EventArgs e)\r\n{\r\n\tstring username = Environment.UserName;\r\n\tstring domainname = Environment.UserDomainName;\r\n\r\n\tlabelUser.Text = username;\r\n\tlabelDomain.Text = domainname;\r\n\r\n\t\/\/ using System.Security.Principal;\r\n\tWindowsIdentity user =\r\n\t\tWindowsIdentity.GetCurrent();\r\n\r\n\t\/\/ \u5c5e\u3057\u3066\u3044\u308b\u30b0\u30eb\u30fc\u30d7\u540d\u4e00\u89a7\u3092\u53d6\u5f97\r\n\tlistBox1.Items.Clear();\r\n\tforeach (var group in user.Groups)\r\n\t{\r\n\t\t\/\/ NT\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u5909\u63db\r\n\t\tNTAccount ac =\r\n\t\t\t(NTAccount)group.Translate(typeof(NTAccount));\r\n\t\tlistBox1.Items.Add(ac.Value);\r\n\t}\r\n\tlistBox1.Sorted = true;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9f\u306f\u3001ActiveDirectry \u3092\u6271\u3046\u305f\u3081\u306b DirectoryEntry, DirectorySearch \u306a\u3093\u304b\u3092\u99c6\u4f7f\u3057\u306a\u3044\u3068\u99c4\u76ee\u306a\u306e\u304b\u306a\u3041\u3001\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u5358\u7d14\u306b\u73fe\u5728\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u306b\u95a2\u3057\u3066\u306a\u3089\u3070\u3001\u30ed &hellip; <a href=\"https:\/\/www.moonmile.net\/blog\/archives\/2320\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,23],"tags":[],"class_list":["post-2320","post","type-post","status-publish","format-standard","hentry","category-dev","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2320"}],"version-history":[{"count":1,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2320\/revisions"}],"predecessor-version":[{"id":2321,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2320\/revisions\/2321"}],"wp:attachment":[{"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}