ASPNET样板或ASPNETZero具有与LDAP集成的能力。显然,配置很简单,但它只允许我配置域、用户和密码。我想知道是否有人有LDAP测试服务器的工作示例?目前,我已经启用了LDAP身份验证:
//Enable LDAP authentication (It can be enabled only if MultiTenancy is disabled!)
Configuration.Modules.ZeroLdap().Enable(typeof(Authorization.Ldap.AppLdapAuthenticationSource));并为其使用测试LDAP服务器。一旦启用了LDAP身份验证,我就会配置域、用户和密码,但是在TokenAuthController.cs中的方法TokenAuthController.cs上会出现一个错误。错误如下:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=System.DirectoryServices.AccountManagement
StackTrace:
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at Abp.Zero.Ldap.Authentication.LdapAuthenticationSource`2.<CreatePrincipalContext>d__13.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Zero.Ldap.Authentication.LdapAuthenticationSource`2.<TryAuthenticateAsync>d__6.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Abp.Authorization.AbpLogInManager`3.<TryLoginFromExternalAuthenticationSources>d__41.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.AbpLogInManager`3.<LoginAsyncInternal>d__37.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.AbpLogInManager`3.<LoginAsync>d__36.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Paradigm.Web.Controllers.TokenAuthController.<GetLoginResultAsync>d__43.MoveNext() in C:\Users\victo\Documents\Work\NS\JNJ\QueDevBase2\src\Paradigm.Web.Core\Controllers\TokenAuthController.cs:line 618
This exception was originally thrown at this call stack:
System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(string, ref System.DirectoryServices.AccountManagement.ServerProperties)
System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
System.DirectoryServices.AccountManagement.PrincipalContext.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType, string, string, System.DirectoryServices.AccountManagement.ContextOptions, string, string)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
Abp.Authorization.AbpLogInManager<TTenant, TRole, TUser>.LoginAsyncInternal(string, string, string, bool)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
...
[Call Stack Truncated]任何帮助都是非常感谢的。
发布于 2020-05-31 18:28:14
当前的Abp.Zero.Ldap使用了PrincipalContext:PrincipalContext - I Can't connect to a local openldap server
对于AD,在DefaultSettingsCreator.cs中添加设置:
AddSettingIfNotExists(LdapSettingNames.UserName, "AD_Administrator", tenantId);
AddSettingIfNotExists(LdapSettingNames.Password, "password", tenantId);
AddSettingIfNotExists(LdapSettingNames.ContextType, "Domain.Context", tenantId);
AddSettingIfNotExists(LdapSettingNames.Domain, "test.local");注意:如果不定义域、用户名和密码,如果应用程序在具有适当权限的域中运行,LDAP身份验证适用于当前域。https://aspnetboilerplate.com/Pages/Documents/Zero/User-Management#settings
用于LDAP在线测试服务器
查看:https://github.com/do-it-ger/DoAspnetboilerplateLdap以获得Novell.Ldap实现。测试在在线Ldap测试服务器上运行: ldap.forumsys.com
https://stackoverflow.com/questions/61802173
复制相似问题