Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] System.DirectoryServices.Protocols is not supported on this platform #77022

Closed
Lemaus123 opened this issue Oct 13, 2022 · 10 comments
Closed
Labels
area-System.DirectoryServices needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration

Comments

@Lemaus123
Copy link

I have error of System.DirectoryServices.Protocols is not supported on this plartform while I'm using 5.18.19-3-MANJARO (64-bit), with the 6.0.9 runtime

The exception is thrown while executing the following statement:

var connection = new LdapConnection(domain);

I tried both versions 6.0.1 and 7.0.0-rc.2.22472.3, and the issue is occurring every time.

I use .NET6 for this project. According to the research I've done, this package should be cross-platform on both Mac and Linux for a few years now, am I missing something to be able to use it?

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 13, 2022
@ghost
Copy link

ghost commented Oct 13, 2022

Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014
See info in area-owners.md if you want to be subscribed.

Issue Details

I have error of System.DirectoryServices.Protocols is not supported on this plartform while I'm using 5.18.19-3-MANJARO (64-bit), with the 6.0.9 runtime

The exception is thrown while executing the following statement:

var connection = new LdapConnection(domain);

I tried both versions 6.0.1 and 7.0.0-rc.2.22472.3, and the issue is occurring every time.

I use .NET6 for this project. According to the research I've done, this package should be cross-platform on both Mac and Linux for a few years now, am I missing something to be able to use it?

Author: Lemaus123
Assignees: -
Labels:

area-System.DirectoryServices

Milestone: -

@vcsjones
Copy link
Member

I have error of System.DirectoryServices.Protocols is not supported on this plartform

What is the exact error you are getting, with a stack trace?

this package should be cross-platform on both Mac and Linux for a few years now, am I missing something to be able to use it?

You do need libldap-2.4.so.2 available on your system. Do note that if your distribution comes with a newer version of libldap like 2.5 or 2.6, there is a known issue loading those. #69456

@Lemaus123
Copy link
Author

Hi there,

Here is the stack trace

System.PlatformNotSupportedException: System.DirectoryServices.Protocols is not supported on this platform.
   at System.DirectoryServices.Protocols.DirectoryConnection..ctor()
   at System.DirectoryServices.Protocols.LdapConnection..ctor(String server)
   at CRM_API.Utilities.GetADUsers() in /home/lopb/Desktop/CRM-API/Utilities.cs:line 16
   at CRM_API.Controllers.UsersController.Get() in /home/lopb/Desktop/CRM-API/Controllers/UsersController.cs:line 16
   at lambda_method3(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

Both libldap and lib32-libldap 2.6.3-1 are already installed on my system.
Those libraries are required for my project since I use postgresql as database.

When I compare the stack trace of the issue you linked and mine, they don't seem to be related.

@vcsjones
Copy link
Member

@Lemaus123 what is the output of dotnet --info on your system, and how are you consuming the package, and what is the <TargetFramework> of your application? It looks like you're getting the default "I don't know what target platform you are on so it's not supported"

<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.DirectoryServicesProtocols_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>

@joperezr
Copy link
Member

Thanks for logging the issue @Lemaus123 and thanks for the replies @vcsjones, indeed this looks like a case where the package is either not consumed correctly or the app is not being deployed correctly, as @Lemaus123 is getting the RIDless configuration as opposed to getting the Linux one. @Lemaus123 if you could share the code inside your .csproj as well as the instructions on how you are deploying and running your app it would be helpful in figuring out what is going on here.

@joperezr joperezr added the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 19, 2022
@ghost
Copy link

ghost commented Oct 19, 2022

This issue has been marked needs-author-action and may be missing some important information.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 19, 2022
@Lemaus123
Copy link
Author

Here is the output of dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.109
 Commit:    58a93139d8

Runtime Environment:
 OS Name:     manjaro
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.109/

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: x64
  Commit:       163a63591c

.NET SDKs installed:
  6.0.109 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]


Here is my .csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>disable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>CRM_API</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="12.0.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.10" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.10" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.10" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.10" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
    <PackageReference Include="Npgsql" Version="6.0.7" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.7" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
    <PackageReference Include="System.DirectoryServices.Protocols" Version="6.0.1" />
  </ItemGroup>

</Project>

I'm using Ryder so i'm not sure what to answer about how i'm running my app since its all automatic.

My coworker use it on the same project on his Windows OS and the package work very well, so the way the package is consumed should not be the problem.

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Oct 22, 2022
@wzchua
Copy link
Contributor

wzchua commented Oct 22, 2022

Related #62554 ?

@Lemaus123
Copy link
Author

With all your help I figured out a way to make this work for now. By adding

    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>

in my .csproj the platform was correctly identified.
I had an error of Unable to load shared library 'libldap-2.4.so.2' or one of its dependencies.. (because the version is hard coded in .net runtime). So I downloaded the libldap24 from the AUR and everything started to work well.

@joperezr
Copy link
Member

Glad you got it to work, closing this as it seems that you are unblocked now.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.DirectoryServices needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

4 participants