System.PlatformNotSupportedException: System.DirectoryServices.AccountManagement is not supported on this platform Windows 10
Hi All.
I'm trying to connect to Active Directory within my company scope, and i setted up a simple test
with dotnet CLI i run:
dotnet add package System.DirectoryServices.AccountManagement --version 4.7.0
with dotnet fsi i run:
#r "C:\\Users\\ABSD\\.nuget\\packages\\system.directoryservices.accountmanagement\\4.7.0\\lib\\netstandard2.0\\System.DirectoryServices.AccountManagement.dll"
open System.DirectoryServices.AccountManagement
let dEntry = new PrincipalContext(ContextType.Domain,"LDAP://server-path:389")
But i receive this error:
System.PlatformNotSupportedException: System.DirectoryServices.AccountManagement is not supported on this platform.
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name)
at <StartupCode$FSI_0012>.$FSI_0012.main@()
Detenido debido a un error.
dotnet --info
SDK de .NET Core (reflejando cualquier global.json):
Version: 3.1.402
Commit: 9b5de826fd
Entorno de tiempo de ejecución:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.402\
Host (useful for support):
Version: 3.1.8
Commit: 9c1330dedd
.NET Core SDKs installed:
3.1.402 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I searched over internet but all the same problem was by using Linux/MAC no information with Windows.
Hey @dnomar , were you able to get passed this problem by any chance? I'm running into it as well. Works fine when running on Windows outside of docker. When containerized, I receive the same error as you.
Thanks.
No, i use an alternative server with iis/.net framework instead and it works. This library does no work if your docker runs over linux or mac is only for windows.
@terrajobst is this related to https://github.com/dotnet/runtime/issues/14734?
System.DirectoryServices.AccountManagement is only supported on Windows. As you noticed, you will get this error when trying to run on Linux, which includes running Linux containers using Docker for Windows.
To track S.DS.AM support for Linux, see dotnet/runtime#37100.
@joeloff, this can probably be closed as a duplicate of that issue.
I am getting same error while debugging:
"System.DirectoryServices.AccountManagement is not supported on this platform."
I am running on Windows. I am targetting
<TargetFramework>net6.0-windows</TargetFramework>
and I use
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="7.0.0" />
package.
I could not find anything that has S.DS.AM in my bin folder.
Can you please advice how to fix this error?
Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014 See info in area-owners.md if you want to be subscribed.
Issue Details
Hi All.
I'm trying to connect to Active Directory within my company scope, and i setted up a simple test
with dotnet CLI i run:
dotnet add package System.DirectoryServices.AccountManagement --version 4.7.0
with dotnet fsi i run:
#r "C:\\Users\\ABSD\\.nuget\\packages\\system.directoryservices.accountmanagement\\4.7.0\\lib\\netstandard2.0\\System.DirectoryServices.AccountManagement.dll"
open System.DirectoryServices.AccountManagement
let dEntry = new PrincipalContext(ContextType.Domain,"LDAP://server-path:389")
But i receive this error:
System.PlatformNotSupportedException: System.DirectoryServices.AccountManagement is not supported on this platform.
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name)
at <StartupCode$FSI_0012>.$FSI_0012.main@()
Detenido debido a un error.
dotnet --info
SDK de .NET Core (reflejando cualquier global.json):
Version: 3.1.402
Commit: 9b5de826fd
Entorno de tiempo de ejecución:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.402\
Host (useful for support):
Version: 3.1.8
Commit: 9c1330dedd
.NET Core SDKs installed:
3.1.402 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
I searched over internet but all the same problem was by using Linux/MAC no information with Windows.
| Author: | voh83 |
|---|---|
| Assignees: | joeloff |
| Labels: |
|
| Milestone: | - |
I am getting same error while debugging: "System.DirectoryServices.AccountManagement is not supported on this platform." I am running on Windows. I am targetting
net6.0-windows
@Turhan8 I don't think your TFM targeting windows matters, the message suggests somehow your app running on non-windows. Anyway tagging @joperezr @BRDPM @grubioe @jay98014 if they have any suggestion for you.
I could not find anything that has S.DS.AM in my bin folder.
What happens when you run: dotnet add package System.DirectoryServices.AccountManagement --version 7.0.0
Does anyone know of any libraries that do support LDAP queries from mac? I had the impression s.ds.protocols did but that gives me a non supported exception also when I try to do a LdapConnection.Bind()
Clarification. I can bind using a NetworkCredential and AuthType.Basic. I'm new to Mac so I don't know the limitations. I know we have some kind of corporate binding on our Mac devices and I can connet to AD SMB shares and visit IIS websites that are using Windows Auth. without being prompted for creds so I'm trying to do similiar. I don't want to have to ask my users to enter their creds unless absolutely needed.
Does anyone know of any libraries that do support LDAP queries from mac? I had the impression s.ds.protocols did but that gives me a non supported exception also when I try to do a LdapConnection.Bind()
Clarification. I can bind using a NetworkCredential and AuthType.Basic. I'm new to Mac so I don't know the limitations. I know we have some kind of corporate binding on our Mac devices and I can connet to AD SMB shares and visit IIS websites that are using Windows Auth. without being prompted for creds so I'm trying to do similiar. I don't want to have to ask my users to enter their creds unless absolutely needed.
S.DS.P is supposed to work fine on MacOS, but I had problems with it. I was using it as a PowerShell library. It was supposed to work and the author of the library bought a Mac Mini to support it, but was unable to replicate the problems I was having.
Macs can authenticate with Windows domains transparently after the user is logged in, but that is only supported at an OS level. That's not a great way to phrase that, but only Apple stuff can get the current Kerberos token and use it for authentication, I'm pretty sure. That token is not made available or made accessible by MacOS for use by other programs, so you can't have your application simply inherit the AD-authenticated user, to my knowledge. What I've done in this case is give the user instructions to run the security tool to add credentials to the Keychain, then use those from the applications I write. Because I didn't know of a working library in C# for this stuff, I've written a LOT of LDAP manipulation stuff in Go, and that's been going great. Lately I discovered that there's a library that's a port from some Novell Java library that is apparently working, but I've not tried it. I'm in Go-land for LDAP, now. Or Powershell if I'm on Windows.