UniStuttgart-VISUS / Visus.LdapAuthentication

LDAP authentication middleware for ASP.NET Core
MIT License
24 stars 8 forks source link

Cannot resolve scoped service 'Visus.LdapAuthentication.ILdapSearchService' from root provider. #8

Closed djaiswal007 closed 4 months ago

djaiswal007 commented 8 months ago

Mentioned in appsetting.json,

"LdapConfiguration": { "Server": "serverdetail", "SearchBase": "DC=abc,DC=com", "Schema": "Active Directory", "IsRecursiveGroupMembership": true, "Port": 636, "IsSsl": true, "IsNoCertificateCheck": true, "User": "sadfsdf", "Password": "asdfsadfsadf" } In startup var options = new LdapOptions(); this.Configuration.GetSection("LdapConfiguration").Bind(options); services.AddLdapSearchService(options);

what am i missing that ILdapSearchService is not getting resolved

crowbar27 commented 8 months ago

I am not sure how to diagnose this without the code where it is used. One thing I can imagine that this is a follow-p error. Can you try to add services.AddLdapConnectionService(options); as well?

djaiswal007 commented 8 months ago

I am working on Ldap search, so this is the only code change that i have to do right. I have posted all the code change i have done for integration

crowbar27 commented 8 months ago

Yes, in principle this should suffice to register the service. However, the error you get should only be raised when you try to inject the service into a controller, not when registering the search service. If it does fail at this point, the only reason I see would be another dependency missing. I just had a look in the code and the only thing required here is the logger. Do you have the logging extensions (https://www.nuget.org/packages/Microsoft.Extensions.Logging/) installed?

crowbar27 commented 4 months ago

Closing this due to inactivity.