Base solution for your next web application

Activities of "peabaw"

Hi

I just activated LDAP through the GUI User Management and tried to log in with an AD user. It failed with internal error. The AD user does not have an email address and it seems this is a requirement currently in ABP/Zero, or am I wrong? How could I work around this to allow non-email AD users to login?

Service: TokenAuthController Action: Authenticate

Error state

System.NullReferenceException: Object reference not set to an instance of an object. at Abp.Authorization.Users.AbpUser1.SetNormalizedNames() at Abp.Authorization.AbpLogInManager3.TryLoginFromExternalAuthenticationSources(String userNameOrEmailAddress, String plainPassword, TTenant tenant) at Abp.Authorization.AbpLogInManager3.LoginAsyncInternal(String userNameOrEmailAddress, String plainPassword, String tenancyName, Boolean shouldLockout) at Abp.Authorization.AbpLogInManager3.LoginAsync(String userNameOrEmailAddress, String plainPassword, String tenancyName, Boolean shouldLockout) at Abp.Threading.InternalAsyncHelper.AwaitTaskWithPostActionAndFinallyAndGetResult[T](Task1 actualReturnValue, Func1 postAction, Action`1 finalAction) at TokenAuthController.GetLoginResultAsync(String usernameOrEmailAddress, String password, String tenancyName) in .Web.Core\Controllers\TokenAuthController.cs:line 521 at Peab.GHR.Web.Controllers.TokenAuthController.Authenticate(AuthenticateModel model) in .Web.Core\Controllers\TokenAuthController.cs:line 107 at lambda_method(Closure , Object ) at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()

Best regards // Andreas

Thank you. I'll try that!

Hello there

I have some problems getting Windows AND anonymous authentication to work. The login process is supposed to be like this:

  1. The user go to the angular site login. It should start an automatic AD/LDAP login process (as described at https://support.aspnetzero.com/QA/Questions/5370).
  2. If successful AD login, the user gets in.
  3. If unsuccessful, the user should return to the login page and be able to login using username and password as normal.

I have gotten some of this to work but when both Anonymous and Windows autentication is active in IIS, the User.Identity.IsAuthenticated is always false making LDAP login always unsuccessful.

I have changed the API web.config attribute forwardWindowsAuthToken="true".

I'm quite new to both IIS with .Net Core and especially Angluar, so any tips would be greatly appreciated!

Best regards // Andreas

I tried and added [Authorized] before the Authenticate method:

[Authorize] public async Task<AuthenticateResultModel> Authenticate([FromBody] AuthenticateModel model)

I now get a populated User.Identity, but it now however fails with "Authorization.Users.UserManager - Invalid password for user X." so I guess something else has gone wrong now.

Am I doing it the right way or should I completely change approach?

Hi @ismcagdas

Unfortunately no. I think the AlwaysTrueExternalAuthSource method will not work on a site with both Windows Auth and Anonymous access. I think it will only work on a site with only Windows Auth. In the db the source is AlwaysTrueExternalAuthSource instead of LDAP which might cause the password error as well.

What I want to do seems to be a special case (thought it would be a common scenario for an entreprise solution to allow local user access and forms login for external users but I seem to be wrong).

I do not have a good lead going forward or any reserve backup plan though. Any tips would therefore be very appreciated!

@ismcagdas

Thank you for all help. Might I just bother you to explain why it might be possible with MVC but not possible with Angular? It might help give me a clue.

Hi

I have created a separate VS Project called Integrations. In this I have created a Module:

public class GHRIntegrationModule : AbpModule
    {
        public override void PreInitialize()
        {
            var configurationAccessor = IocManager.Resolve<IAppConfigurationAccessor>();
            var connectionString = configurationAccessor.Configuration["ConnectionStrings:ProjectSearch"];

            if (string.IsNullOrEmpty(connectionString))
            {
                //Use fake project search if database connection string is empty
                IocManager.Register<IProjectDataProvider, FakeProjectDataProvider>(DependencyLifeStyle.Singleton);
            }
            else
            {
                IocManager.Register<IProjectDataProvider, ProjectDataProvider>(DependencyLifeStyle.Singleton);
                var projectDataProvider = Configuration.Get<ProjectDataProvider>();
                projectDataProvider.DbConnectionString = connectionString;
            }
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(GHRIntegrationModule).GetAssembly());
        }
    }

The project currently contains a single AppService:

[AbpAuthorize]
    public class ProjectAppService : IProjectAppService
    {
        private readonly IProjectDataProvider _projectDataProvider;

        public ProjectAppService(IProjectDataProvider projectDataProvider)
        {
            _projectDataProvider = projectDataProvider;
        }

        [AbpAuthorize]
        public async Task<ProjectDto> GetProject(GetProjectInput input)
        {
            return await _projectDataProvider.GetProject(input);
        }

        [AbpAuthorize]
        public async Task<List<ProjectDto>> SearchProjects(SearchProjectInput input)
        {
            return await _projectDataProvider.SearchProjects(input);
        }
    }

I thought that the AppService would be picked up by the auto API controller creator and included in the API but it does not show up in Swagger for example so something is missing.

I have tried to add a call to create the controller for the app service but no change. I tried to add the following to the WebCoreModule PreInitialize and my own module's PreInitialize:

Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(GHRIntegrationModule).GetAssembly()
                );

I think I am only missing something easy and obvious.

Any tips wpuld be very appreciated!

Ah, that got me going in the right way. It now works.

It had also to add my Module to the WebCoreModule:

[DependsOn(
    ...
        typeof(GHRIntegrationModule),
   ....
       )]
    public class GHRWebCoreModule

And lastly add this to WebCoreModule.PreInitialize():

Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(GHRIntegrationModule).GetAssembly()
                );

Thank you @ryancyq!

@alper

I think all of those links concerns Windows authentication only unfortunately. I have yet to find a guide for BOTH Windows and Anonymous authentication, especially with Angular och WebApi.

My conclusion is that this might actually not be possible to do. Any ideas to "a workaraound"? Two sites, one each for every login? Some sort of external login solution who does the dual-authentication (i.e. first Windows, then forms login)?

Hello there

The LanguageAppService gives us a possibility to edit a language text:

public async Task UpdateLanguageText(UpdateLanguageTextInput input)

But why is there no Create?

public async Task CreateLanguageText(CreateLanguageTextInput input)

I guess there is a very good reason for that that I missed, so please hit me in the head with that explenation!

I'm asking because we need to dynamically create translatable language texts from the GUI to be used in the application. We are creating forms with 1..N inputs with labels, and these labels must be translatable. I thought I would be able to use the language DB in Zero and just create then through API but am I right that I need to implement a separate DB for this?

Solution: Asp.Net Zero angular+webapi

Showing 1 to 10 of 22 entries