{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/24488","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/24488/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/24488/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/24488/events","html_url":"https://github.com/dotnet/corefx/issues/24488","id":263566927,"number":24488,"title":"System.IO.FileNotFoundException System.DirectoryServices.AccountManagement","user":{"login":"Petermarcu","id":8228359,"avatar_url":"https://avatars3.githubusercontent.com/u/8228359?v=4","gravatar_id":"","url":"https://api.github.com/users/Petermarcu","html_url":"https://github.com/Petermarcu","followers_url":"https://api.github.com/users/Petermarcu/followers","following_url":"https://api.github.com/users/Petermarcu/following{/other_user}","gists_url":"https://api.github.com/users/Petermarcu/gists{/gist_id}","starred_url":"https://api.github.com/users/Petermarcu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Petermarcu/subscriptions","organizations_url":"https://api.github.com/users/Petermarcu/orgs","repos_url":"https://api.github.com/users/Petermarcu/repos","events_url":"https://api.github.com/users/Petermarcu/events{/privacy}","received_events_url":"https://api.github.com/users/Petermarcu/received_events","type":"User","site_admin":false},"labels":[{"id":411515101,"url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.DirectoryServices","name":"area-System.DirectoryServices","color":"d4c5f9","default":false},{"id":145399955,"url":"https://api.github.com/repos/dotnet/corefx/labels/bug","name":"bug","color":"207de5","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-10-06T20:46:01Z","updated_at":"2017-10-27T15:28:23Z","closed_at":"2017-10-27T15:28:23Z","author_association":"MEMBER","body":"@CarlosOnline commented on [Fri Sep 15 2017](https://github.com/dotnet/core/issues/970)\n\n# System.DirectoryServices.AccountManagement won't load from asp.net Core 2.0 (netcoreapp2.0) website\r\nReferencing .net 4.5.1 framework class library from asp.net Core 2.0 (netcoreapp2.0), where class library references System.DirectoryServices.AccountManagement leads to receives FileNotFound exception.  \r\n\r\n**System.IO.FileNotFoundException** occurred\r\n  HResult=0x80070002\r\n  Message=Could not load file or assembly '**System.DirectoryServices.AccountManagement**, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.\r\n  Source=<Cannot evaluate the exception source>\r\n  StackTrace:\r\n   at SUR.Util1.ActiveDirectory.GetGroupNames(String userName) in combined\\Util1\\ActiveDirectory.cs:line 33\r\n   at spa.Controllers.HomeController.Index() in combined\\spa\\Controllers\\HomeController.cs:line 15\r\n   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)\r\n   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()\r\n\r\n# Repro\r\nProblem solution uploaded to [DotNetCore2DirectoryServicesBug](https://github.com/CarlosOnline/DotNetCore2DirectoryServicesBug)\r\n\r\n# Manual Repro\r\ndotnet new aurelia\r\nnpm install\r\nadd new **Utils** .Net Framework 4.51 project _(version doesn't matter)_\r\nadd class below to Utils .Net Framework 4.51\r\n\r\n```\r\n    public class ActiveDirectory\r\n    {\r\n        public static List<string> GetGroupNames(string userName)\r\n        {\r\n            var result = new List<string>();\r\n\r\n            if (string.IsNullOrEmpty(userName))\r\n                return result;\r\n\r\n            var domain = userName.Split('\\\\').FirstOrDefault();\r\n\r\n            var pc = new PrincipalContext(ContextType.Domain, domain);\r\n            var identity = UserPrincipal.FindByIdentity(pc, userName);\r\n            if (identity != null)\r\n            {\r\n                var src = identity.GetGroups(pc);\r\n                src.ToList().ForEach(sr => result.Add(sr.SamAccountName));\r\n            }\r\n            return result;\r\n        }\r\n\r\n    }\r\n```\r\nadd **Utils** project reference to asp.net core app project\r\nupdate HomeController.cs\r\n```\r\n    public class HomeController : Controller\r\n    {\r\n        public IActionResult Index()\r\n        {\r\n            var groups = ActiveDirectory.GetGroupNames(User.Identity.Name);\r\n\r\n            return View();\r\n        }\r\n    }\r\n```\r\nstart debugging\r\n\n\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/340004129","html_url":"https://github.com/dotnet/corefx/issues/24488#issuecomment-340004129","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/24488","id":340004129,"user":{"login":"tarekgh","id":10833894,"avatar_url":"https://avatars2.githubusercontent.com/u/10833894?v=4","gravatar_id":"","url":"https://api.github.com/users/tarekgh","html_url":"https://github.com/tarekgh","followers_url":"https://api.github.com/users/tarekgh/followers","following_url":"https://api.github.com/users/tarekgh/following{/other_user}","gists_url":"https://api.github.com/users/tarekgh/gists{/gist_id}","starred_url":"https://api.github.com/users/tarekgh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarekgh/subscriptions","organizations_url":"https://api.github.com/users/tarekgh/orgs","repos_url":"https://api.github.com/users/tarekgh/repos","events_url":"https://api.github.com/users/tarekgh/events{/privacy}","received_events_url":"https://api.github.com/users/tarekgh/received_events","type":"User","site_admin":false},"created_at":"2017-10-27T15:28:23Z","updated_at":"2017-10-27T15:28:23Z","author_association":"MEMBER","body":"@CarlosOnline your app is netcore app and not full framework app, so it makes sense to load the net core bits and not the full framework bits. This is similar to any other core types (e.g. String for instance) which expected to load the net core type and not the full framework.\r\n\r\nCC @safern "}}
{"actor":{"display_login":"tarekgh"}}