Can anyone let me know on how to access Umbraco services like logger service , member service, user service in start up class file. I want to assign a different role based on the claims I receive from external identity like Azure active directory.
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
adOptions.SetExternalSignInAutoLinkOptions(
new ExternalSignInAutoLinkOptions(autoLinkExternalAccount: true, defaultUserGroups: null, defaultCulture: null)
{
OnAutoLinking = (user, externalLogin) => {
}
,OnExternalLogin = (user, externalLogin) => {
return true;
}
});
}
}
I have the same question. How do we access services in Umbraco 9 during ConfigureServices? Specifically, when the OnExternalLogin action is run, I would like to be able to modify a user by accessing the IBackOfficeUserManager.
I've tried getting the service using an IServiceProvider like so
var provider = services.BuildServiceProvider();
_userManager = provider.GetService<IBackOfficeUserManager>();
But I seem to get errors that
Register called when MainDom has not been acquired
Umbraco.Core.Composing doesn't exist in Umbraco 9, and doesn't seem like a very .Net 5 way of doing things anyway.
Accessing Umbraco services in startup class.
Hi,
Can anyone let me know on how to access Umbraco services like logger service , member service, user service in start up class file. I want to assign a different role based on the claims I receive from external identity like Azure active directory.
Hi Nagarjuna,
You can consume services like this
Example
Userservice
Regards Dhanesh :)
I have the same question. How do we access services in Umbraco 9 during ConfigureServices? Specifically, when the OnExternalLogin action is run, I would like to be able to modify a user by accessing the IBackOfficeUserManager.
I've tried getting the service using an IServiceProvider like so
But I seem to get errors that
Umbraco.Core.Composing doesn't exist in Umbraco 9, and doesn't seem like a very .Net 5 way of doing things anyway.
Any ideas?
is working on a reply...