ASPNET Boilerplate或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中的GetLoginResultAsync方法上得到一个错误。错误如下。
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]
希望能得到帮助
目前Abp.Zero.Ldap使用的是PrincipalContext。PrincipalContext - 我不能连接到本地openldap服务器
对于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.comPagesDocumentsZeroUser-Management#settings。
检查出来。https:/github.comdo-it-gerDoAspnetboilerplateLdap。 的Novell.Ldap实现。测试运行在在线 Ldap 测试服务器上:ldap.forumys.com。