Activities of "s.alshammari.c"

Answer

I configured my smtp server and I am getting this exception

Failure sending mail. System.Net.Mail.SmtpException: Failure sending mail.  ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)  at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)  at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)

I solved the issue

problem was on class VoloLdapExternalLoginProvider

before

after

I had to add the domain here

here is my code

using Microsoft.AspNetCore.Identity; using System.Threading.Tasks; using Volo.Abp.Features; using Volo.Abp.Guids; using Volo.Abp.Identity.ExternalLoginProviders.Ldap; using Volo.Abp.Identity; using Volo.Abp.Ldap; using Volo.Abp.MultiTenancy; using Volo.Abp.Settings; using Microsoft.Extensions.Options; using LdapForNet;

namespace TestApp.Web { public class VoloLdapExternalLoginProvider : LdapExternalLoginProvider { public VoloLdapExternalLoginProvider( IGuidGenerator guidGenerator, ICurrentTenant currentTenant, IdentityUserManager userManager, IIdentityUserRepository identityUserRepository, OpenLdapManager ldapManager, ILdapSettingProvider ldapSettingProvider, IFeatureChecker featureChecker, ISettingProvider settingProvider, IOptions<IdentityOptions> identityOptions) : base(guidGenerator, currentTenant, userManager, identityUserRepository, ldapManager, ldapSettingProvider, featureChecker, settingProvider, identityOptions) {

    }

    protected override async Task&lt;string&gt; NormalizeUserNameAsync(string userName)
    {
        // Default is $"uid={userName}, {BaseDc}"
        // or "userName@domain 
        //await LdapSettingProvider.GetDomainAsync();
      var loginUserName= await Task.FromResult($"{userName}");
        return loginUserName;
    }



    
}

}


using LdapForNet; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Identity.ExternalLoginProviders.Ldap; using Volo.Abp.Ldap;

namespace TestApp.Web { [Dependency(ReplaceServices = true)] [ExposeServices(typeof(OpenLdapManager), typeof(ILdapManager), typeof(LdapManager))] public class VoloOpenLdapManager : OpenLdapManager { public VoloOpenLdapManager(ILdapSettingProvider ldapSettingProvider) : base(ldapSettingProvider) {

    }

    protected override async Task&lt;string&gt; NormalizeUserNameAsync(string userName)
    {
        // or "userName@domain 
        //await LdapSettingProvider.GetDomainAsync();
        return await Task.FromResult($"{userName}");
    }

    protected override Task&lt;string&gt; GetUserFilterAsync(string userName)
    {
        // Default is $"cn={userName},{LdapOptions.BaseDc}"
        return Task.FromResult($"(&(objectClass=user)(sAMAccountName={userName}))");
        
    }

    protected override Task&lt;string&gt; GetUserEmailAsync(LdapEntry ldapEntry)
    {
        return Task.FromResult(ldapEntry.ToDirectoryEntry().GetAttribute("mail")?.GetValue&lt;string&gt;());
        
    }
}

}

its working on AbpLdapSamle

in my app some users successfully logged and some other users trigger the error above, they all have same attribute i don't know why some users can login and others cannot.

this user logged in successfully

this user cannot login and i get invalid username/password in login page

ok Good

now once I login with right credentials

I get this.

keep in mind this is only happening on login page and not when importing users

I have the mail attribute in AD and also the same code you sent and I still have this issue Exception: Unable to get the email of ldap user!

when I import user like this

it work

but when I try to login from login page I get this exception

Exception: Unable to get the email of ldap user!

I managed to integrate the AD and my App successfully but now I get this Exception when i try to login

Exception: Unable to get the email of ldap user!

I followed what you did and it works fine. I noticed that you are using

filter="(&(uid=testuser))

I don't have uid in my AD

instead of using uid i would like to use sAMAccountName because I used it in the AbpLDAPSample

and it worked

so

how can I change filter="(&(uid=testuser)) to (&(objectClass=user)(sAMAccountName={testuser})

this is the log

[10:13:48 INF] Executing endpoint '/Account/Login' [10:13:48 INF] Route matched with {page = "/Account/Login", action = "", controller = "", area = ""}. Executing page /Account/Login [10:13:48 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy [10:13:48 INF] Executing handler method Volo.Abp.Account.Public.Web.Pages.Account.LoginModel.OnPostAsync - ModelState is Valid [10:13:48 INF] Try to use LDAP for external authentication [10:13:48 ERR] Invalid Credentials. Invalid Credentials. Result: 49. Method: ldap_parse_result. Details: errorMessage: 80090308: LdapErr: DSID-0C090439, comment: AcceptSecurityContext error, data 52e, v4563 matchedMessage: LdapForNet.LdapInvalidCredentialsException: Invalid Credentials. Invalid Credentials. Result: 49. Method: ldap_parse_result. Details: errorMessage: 80090308: LdapErr: DSID-0C090439, comment: AcceptSecurityContext error, data 52e, v4563 matchedMessage:  at LdapForNet.Native.LdapNative.ThrowIfError(SafeHandle ld, Int32 res, String method, IDictionary`2 details)  at LdapForNet.LdapConnection.ThrowIfParseResultError(IntPtr msg)  at LdapForNet.LdapConnection.BindAsync(LdapAuthType authType, LdapCredential ldapCredential)  at Volo.Abp.Ldap.LdapManager.AuthenticateLdapConnectionAsync(ILdapConnection connection, String username, String password)  at Volo.Abp.Ldap.LdapManager.AuthenticateAsync(String username, String password)

I tried AbpLdapSample and its working. However, I still have issue with my App as I mentioned earlier

Showing 31 to 40 of 40 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11