Hello there,
We extended the LdapAuthenticationSource in order to use it on linux environment via Novell library. Sometimes, Domain Controller does not respond within the predefined timeout, however, the application still logs me in although TryAuthenticateAsync method is returning false. We want users to only use their LDAP accounts, and on each login, we must precheck their existence and update their passwords accordingly in our system. However, as I have logged in before, probably, I am an already-registered user so I can log in although LDAP connection fails.
using System;
using System.Threading.Tasks;
using Abp.Configuration;
using Abp.Zero.Ldap.Authentication;
using Abp.Zero.Ldap.Configuration;
using Microsoft.Extensions.Logging;
using Novell.Directory.Ldap;
using PPM.Authorization.Users;
using PPM.MultiTenancy;
namespace PPM.Authorization.Ldap
{
public class AppLdapAuthenticationSource : LdapAuthenticationSource<Tenant, User>
{
private readonly string _ldapDomain;
private readonly string _ldapUserName;
private readonly string _ldapPassword;
private readonly ILogger<AppLdapAuthenticationSource> _logger;
private readonly ILdapConnectionFactory _ldapConnectionFactory;
public AppLdapAuthenticationSource(ILdapSettings settings, IAbpZeroLdapModuleConfig ldapModuleConfig,
ISettingManager settingManager, ILogger<AppLdapAuthenticationSource> logger, ILdapConnectionFactory ldapConnectionFactory)
: base(settings, ldapModuleConfig)
{
_logger = logger;
_ldapConnectionFactory = ldapConnectionFactory;
_ldapDomain = settingManager.GetSettingValueAsync(LdapSettingNames.Domain).Result;
_ldapUserName = settingManager.GetSettingValueAsync(LdapSettingNames.UserName).Result;
_ldapPassword = settingManager.GetSettingValueAsync(LdapSettingNames.Password).Result;
}
public override Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword,
Tenant tenant)
{
var userDn = $"{userNameOrEmailAddress}@{_ldapDomain}";
try
{
using (var connection = _ldapConnectionFactory.Create(10000))
{
connection.Connect(_ldapDomain, LdapConnection.DefaultPort);
connection.Bind(userDn, plainPassword);
if (connection.Bound)
{
return Task.FromResult(true);
}
}
}
catch (LdapException e)
{
_logger.LogInformation("Ldap Connection Error : " + e.Message);
}
return Task.FromResult(false);
}
public override async Task<User> CreateUserAsync(string userNameOrEmailAddress, Tenant tenant)
{
await CheckIsEnabled(tenant);
var user = new User
{
UserName = userNameOrEmailAddress,
Name = userNameOrEmailAddress,
Surname = userNameOrEmailAddress,
EmailAddress = userNameOrEmailAddress,
IsEmailConfirmed = true,
IsActive = true
};
var ldapUser = GetLdapUserDetail(user.UserName);
return SetUserWithLdapDetail(user, ldapUser);
}
public override async Task UpdateUserAsync(User user, Tenant tenant)
{
await CheckIsEnabled(tenant);
var ldapUser = GetLdapUserDetail(user.UserName);
SetUserWithLdapDetail(user, ldapUser);
}
private LdapEntry GetLdapUserDetail(string userName)
{
var userDn = $"{_ldapUserName}@{_ldapDomain}";
using (var connection = _ldapConnectionFactory.Create(10000))
{
connection.Connect(_ldapDomain, LdapConnection.DefaultPort);
connection.Bind(userDn, _ldapPassword);
var searchFilter = string.Format("sAMAccountName={0}", userName);
var result = connection.Search("DC=******,DC=local",
LdapConnection.ScopeSub,
searchFilter,
new[]
{
"samaccountname", "givenName", "sn", "mail"
},
false
);
var ldapUser = result.Next();
return ldapUser ?? null;
}
}
private User SetUserWithLdapDetail(User user, LdapEntry ldapUser)
{
var samAccountName = ldapUser.GetAttribute("samaccountname").StringValue;
var givenName = ldapUser.GetAttribute("givenName").StringValue;
var surName = "";
try
{
surName = ldapUser.GetAttribute("sn").StringValue;
}
catch
{
// ignored
}
var mail = ldapUser.GetAttribute("mail").StringValue;
if (!string.IsNullOrEmpty(samAccountName))
{
user.UserName = samAccountName;
}
user.Name = givenName;
user.Surname = surName;
user.EmailAddress = mail;
user.IsActive = true;
return user;
}
}
}
Since we are calling webapi's from our other projects via server-to-server communication, this interceptor does not work for our case.
Hello,
I inspected the XmlEmbeddedFileLocalizationDictionaryProvider's source code and saw that there is no way to support case-insensitivity in terms of keys, except from rewriting the whole provider. Mistakenly in the development phase, we had this trouble a lot; for example, L("Products") and L("products") produces different results. This is very inconvenient for our projects and in my opinion, it should be enabled via configuration or replacing the provider?
@maliming you are right, however, AspnetZero does inject the response type, which is wrong, either. The service should return the same structure as it promises to.
In my opinion, instead of wrapping results, RAD tool should generate wrapped object results (such as AbpPagedResult<T> ) so that Swagger will generate related structure.
Hi there,
We now have a couple of finished AspnetZero applications, and we started using some of their api's like login and other methods. However, the same nswag problem starts occurring: nswag generated unwrapped results.
In my opinion, you can pass such a lambda function:
Configuration.Modules.AbpAspNetCore().DefaultWrapResultAttribute.WrapOnSuccessFunc = (request) => request.Headers["x-dontwrap"] != null;
So that we can configure it per httprequest?
What we do is now create an overload for unwrapped version and use [DontWrap] Attribute, which is very weird.
It is 1.9.0, not the latest one
Hello,
For Angular project, Consider I have a relation for ProductType entity, which is being referenced by multiple entities. RAD Tool generates same lookup views/typescript files with same names. This causes runtime errors saying that lookup modal cannot be found.
My expectation from the tool was; generate all lookup views to a shared/lookups folder, which would be used like UserControls, instead of generating the same code for every entity. This would both clear the error and reduce the project complexity. In this case, if I need any change on a lookup table, I would create a specific copy for an entity.
Could you investigate and at least, provide an option to do such generation?
Thanks.
Example build log for costCenter lookup, which already exists more than once in our project.
[09:14:15]
[09:14:15]ERROR in : Cannot determine the module for class CostCenterLookupTableModalComponent in C:/BuildAgent3/work/7f7ed20eb034bcff/src/app/main/service/calculationOpexDistributions/costCenter-lookup-table-modal.component.ts! Add CostCenterLookupTableModalComponent to the NgModule to fix it.
[09:14:15]Cannot determine the module for class FinancialItemLookupTableModalComponent in C:/BuildAgent3/work/7f7ed20eb034bcff/src/app/main/service/calculationOpexDistributions/financialItem-lookup-table-modal.component.ts! Add FinancialItemLookupTableModalComponent to the NgModule to fix it.
[09:14:15]
[09:14:15]npm ERR! code ELIFECYCLE
[09:14:15]npm ERR! errno 1
[09:14:15]npm ERR! [email protected] publish: node --max_old_space_size=8192 "./node_modules/@angular/cli/bin/ng" build --prod
[09:14:15]npm ERR! Exit status 1
[09:14:15]npm ERR!
[09:14:15]npm ERR! Failed at the [email protected] publish script.
[09:14:15]npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[09:14:15]
[09:14:15]npm ERR! A complete log of this run can be found in:
[09:14:15]npm ERR! C:\Users\usralm\AppData\Roaming\npm-cache_logs\2019-06-25T06_14_15_841Z-debug.log
[09:14:15]Process exited with code 1
We needed this solution just because of a reverse proxy need actually. Our front-end deployment is open to the public internet, however, backend deployment is not. So, end users' browser cannot contact backend server via ajax requests.
Hello there,
We tried the SSR feature of angular universal library with this aspnetzero template. I wasted a whole day fixing issues with the template. Some of them were events (like LazyLoadEvent, MouseEvent), the other were related to HandsonTable. It seems, both aspnetzero and Handsontable does not support SSR feature?
If it does, could you please explain the issue since we did not change the default modules within the template, it should have been easily done via npm run build:ssr && npm run serve:ssr command.
Link: https://tudip.com/blog-post/angular-server-side-rendering/