Problems with Directory Services and Account Management in ASP.NET Core

Viewed 4494

I have a ASP.NET Core API project and I'd like to utilize DirectoryServices and DirectoryServices.AccountManagement namespaces.

After some research I thought I found some project.json references that would work:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": {
      "frameworkAssemblies": {
        "System.DirectoryServices": "4.0.0.0",
        "System.DirectoryServices.AccountManagement": "4.0.0.0"
      }
    },
    "dnxcore50": { },
    "net451": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

After adding those, code that used classes from those references suggested the namespaces to add to the class:

using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;

After that intellisense had no complaints and everything looked perfect, however if I try to build or run the project I get "type or namespace name 'DirectoryServices' does not exist in the namespace 'System'" errors.

Is there a resource out there can help me figure out how to implement DirectoryServices and DirectoryServices.AccountManagement in ASP.Net 5?

As a side note I like ASP.NET Core but it seems like having to manually create a json file for references is a big step back from adding references in MVC 5 where you just had to find them and check the box to add them. Makes me wonder if there isn't something I'm missing that can generate that file for you rather than needing to know the exact characters and pasting them in yourself to get things working.

3 Answers
Related