Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "klainer"

Hi, I want to extend base AbpMvcAuthorizeFilter (OnAuthorization method) due to custom loging level implementation. I noticed that filter is registered there: AbpWebMvcModule.cs

It is possible to replace this base filter with my own ? How can I do that in WEB module ? Thanks for your time and help!

Hello, I´m using kendo grid, with ABP. I have services, which return IQueriable<T> to Web project. I need to use Kendo ToDataSourceResult extension method to filter data based on request params.

DataSourceResult result = gridViews.ToDataSourceResult(request);

But ABP always dispose DB context, so i got exception.

My example:

GridViewDto:

public class GridView : Entity, IMustHaveOrganizationUnit
    {
        public virtual long OrganizationUnitId { get; set; }

        public virtual string ViewName { get; set; }

        [Required]
        public virtual string Key { get; set; }  // název grigu

        [Required]
        public virtual string GridSettings { get; set; }

        [ForeignKey("User_Id")]
        public virtual User User { get; set; } 
        public long? User_Id { get; set; }
    }

    public class GridViewDto
    {
        public virtual string ViewName { get; set; }
        public virtual string Key { get; set; }  // název grigu
        public virtual string GridSettings { get; set; }
        public virtual string UserName { get; set; }
        public long? UserId { get; set; }
    }

SERVICE:

[UnitOfWork]
        public IQueryable<GridViewDto> GetUserGridViews(User user, string key)
        {
            if (user == null)            
                throw new ArgumentNullException("user");

            Mapper.Initialize(cfg =>
                cfg.CreateMap<GridView, GridViewDto>()
                    .ForMember(dto => dto.UserName, conf => conf.MapFrom(ol => ol.User.Name))
                );


            return _gridViewRepository.GetAll().Where(grid => grid.User_Id == user.Id && grid.Key == key).ProjectTo<GridViewDto>();
        }

CONTROLLER:

[DontWrapResult]
        [UnitOfWork]
        public async Task<ActionResult> GridViewDataRead([DataSourceRequest]DataSourceRequest request, string gridId)
        {
            var user = await _userManager.GetUserByIdAsync(AbpSession.UserId.Value);
            var gridViews = _gridViewService.GetUserGridViews(user, gridId);
            DataSourceResult result = gridViews.ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
System.InvalidOperationException: The operation cannot be completed because the DbContext has been disposed. 
at System.Data.Entity.Internal.InternalContext.CheckContextNotDisposed() 
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 
at System.Data.Entity.Internal.InternalContext.Initialize()

Thanks for help

Hello, I need to extend OU unit entity with some property, is this even possible ? If so, What is proper way to do that ? I need to store aditional data about entity (another code), only for manage users..

Thanks for tips!

Hello

I need to use AspNetWindowsTokenRoleProvider with ABP together. In web.config a created these configuration:

<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
  <providers>
    <clear />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  </providers>
</roleManager>

When I run application I have this problem:

Windows Identity Method is only supported if the user name parameter matches the user name in the current Windows Identity.

This error occurs only when I use ClaimsIdentity to login User. When I login user with WindowIdentity I got another problem with application. My ClaimsIdentity have the same UserName but no work :/

So it is possible to create ClaimsIdentity which work with this role manager ? I need to get USER ActiveDirectory UserGroups / Roles and use it like this:

var User = System.Web.HttpContext.Current.User;
if (User.IsInRole("DOMAIN\\group")){  ...    }

Have anybody solution for windows auto sign on to ABP and use this manager ?

Thanks for HELP !

i have this resource localizable attribute:

public class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
    public LocalizedDisplayNameAttribute(string resourceId)
        : base(GetMessageFromResource(resourceId))
    {

    }

    private static string GetMessageFromResource(string resourceId)
    {
        var ioc = Abp.Dependency.IocManager.Instance;
        var localizationManager = ioc.IocContainer.Resolve<ILocalizationManager>();


        return localizationManager.GetString(MMMConsts.LocalizationSourceName, resourceId, Thread.CurrentThread.CurrentUICulture);}

When I switch language in WEB app, and debug this, In Thread.CurrentThread.CurrentUICulture i still the same value.

But when do this in Razor view culture has changed correctly.

How can I setUp currencu culture in my attribute class , I need it for loading multilanguages texts from resources.

Model attributes are initialized before app start ? Thanks for help !

Solved by this code:

public LocalizedDisplayNameAttribute(string resourceKey)
            : base(resourceKey)
        {
            ResourceKey = resourceKey;
        }

        public string ResourceKey { get; set; }

        public override string DisplayName
        {
            get
            {
                string value = null;
                var ioc = Abp.Dependency.IocManager.Instance;
                var localizationManager = ioc.IocContainer.Resolve<ILocalizationManager>();
                value = localizationManager.GetString(MMMConsts.LocalizationSourceName, ResourceKey, Thread.CurrentThread.CurrentUICulture);

                return value;
            }
        }

c# asp.net-mvc

i have this entity Page:

public class Page : FullAuditedEntity<int, User>, IMultiLanguageEntity<PageTranslation>
{

    public string Name { get; set; }
    public string Content{ get; set; }

    public Page()
    {
        Translations = new List<PageTranslation>();
    }

    public virtual IList<PageTranslation> Translations { get; set; }
}

And entity PageTranslation:

[Table("PageTranslations")]
public class PageTranslation : Entity<int>, IEntityTranslation<Page>
{
    public Page Core { get; set; }
    public int CoreId { get; set; }
    public string Language { get; set; }

    public string Name { get; set; }
    public string Content{ get; set; }
}

I want to update page entity with updated values and tranlsations, so I call this service:

public void UpdatePage(UpdatePageInput input)
    {
        var item = _pageRepository.Get(input.Id);
        item.Content = input.Content;
        item.Description = input.Description;
        item.Title = input.Title;
        item.Name = input.Name;
        item.Translations.Clear(); // there is a problem
        item.Translations.addRange(input.Translations);
    }

When I call item.Translations.Clear() method I got this exception:

The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.

How to solve this in ABP ?

Thanks for help !

Hello, I have question, how auto SignIn user with LDAP auth source. User no need password only his windows username, so if logged to windows is automticly logged to application / no login form need.

Where can i put this logic ? SignIn method in ABP need password / i do not have it because I can not get it from Windows...

Scenario:

1)User is logged in windows 2)User start brower with aplication 3) Aplication get windows username ang check if username exist in LDAP server 4) If it is OK - user is logged, / (ABP framework create record about user in AbpUser table (if not exist) -- this only for permission and role managment).

I have one idea to use Login(username, pass) method from Form base auth, and after user come to page and is logged by windows auth, perform this method in base constructor of controller using windows username (if LDAP auth do not have this username auth failded and user is redirected) Do you have better solution ? Is redirection possible in constructor of Controller ?

I also tried enable windows auth -> enable in web.config. But I got this error: Request filtering is configured on the Web server to deny the request because the query string is too long.

Is even posible to use windows auth with ABP and LDAP and Abp.User / Roles table ?

Thanks for help!

PS: Small question. What if I want to grand permissions for users in ActiveDirecotry db / in AbpUser is single record showed after login. Active Directory have xxxx users?

Hello, I´m traing to do role permission managment. So I created custom permissions:

var administration = context.CreatePermission("Administration", new LocalizableString("Administration", "MND"));

            var pageManagement = administration.CreateChildPermission("Administration.PageManagement", new LocalizableString("PageManagement", "TT"));
            pageManagement.CreateChildPermission("Administration.PageManagement.DeletePage", new LocalizableString("Delteting", "TT"));
            pageManagement.CreateChildPermission("Administration.PageManagement.CreatePage", new LocalizableString("Creating", "TT"));
            pageManagement.CreateChildPermission("Administration.PageManagement.EditPage", new LocalizableString("Editing", "MND"));

            var roleManagement = administration.CreateChildPermission("Administration.RoleManagement", new LocalizableString("RoleManagement", "TT"));
            roleManagement.CreateChildPermission("Administration.RoleManagement.DeleteRole", new LocalizableString("Delteting", "TT"));
            roleManagement.CreateChildPermission("Administration.RoleManagement.CreateRole", new LocalizableString("Creating", "TT"));
            roleManagement.CreateChildPermission("Administration.RoleManagement.EditRole", new LocalizableString("Editing", "TT"));

I want to store information about granted permissions for ROLE in DB like you have it in ABP.Zero.

For that I used RoleAppService:

public async Task UpdateRolePermissions(UpdateRolePermissionsInput input)
        {
            var role = await _roleManager.GetRoleByIdAsync(input.RoleId);
            var grantedPermissions = _permissionManager
                .GetAllPermissions()
                .Where(p => input.GrantedPermissionNames.Contains(p.Name))
                .ToList();

            await _roleManager.SetGrantedPermissionsAsync(role, grantedPermissions);
        }

Input data: RoleId: X GrantedPermissionNames: Administration, Administration.RoleManagement, Administration.RoleManagement.DeleteRole

When i change permissions by UpdateRolePermissions , where are chnages strored ? If they are not stored what is purpose od this method ?

But when i call this method nothing is happen. In db (AbpPermissions) are not any changes. What I´m doing wrong ? Thnks !

Update: I notice, tahat after calling these method:
SetGrantedPermissionsAsync(role, grantedPermissions); GrantPermissionAsync(role, VARIABLE); ProhibitAllPermissionsAsync(role);

I also try this, but permission do not savr to db:/

public async Task UpdateRolePermissions(UpdateRolePermissionsInput input)
        {
            var role = await _roleManager.GetRoleByIdAsync(input.RoleId);
            var grantedPermissions = _permissionManager
                .GetAllPermissions()
                .Where(p => input.GrantedPermissionNames.Contains(p.Name))
                .ToList();



            if (role != null)
            {
                if (grantedPermissions.Count > 0)
                {

                    foreach (var item in grantedPermissions)
                    {
                         _roleStore.AddPermissionAsync(role, new PermissionGrantInfo(item.Name, false));
                         //_roleManager.GrantPermissionAsync(role, item);
                    }

               
                }
                else
                {
                     await _roleManager.ProhibitAllPermissionsAsync(role);
                }
            }

        }

DB table [AbpPermissions] completly freeze.. After call these methods in the sql managment studio cannot select items. ABP LOCK this table ? Some Bug ?

Hello, i often need to use another table for users, mostly is a VIEW from another system like Active Directory. Is is possible to have custom View table for users and using role, permission and another good functionality of ABP ?

My poople view look like:

PeopleView: Login, Department, Email with thousands of row.

User will be automaticly logged to system by his login - Windows Auth.

Do anybody have the same problem ?

Thanks !

Hello,

I need to override default SMTP server setting configuration. I created this class:

public class MySettingProvider : SettingProvider
    {
        public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
        {
            return new[]
                    {
                    new SettingDefinition(
                        "SmtpServerAddress",
                        "192.168.50.14"
                        )
                };
        }
    }

And in Web.Module I´m calling this:

public override void PreInitialize()
 {
            Configuration.Settings.Providers.Add<MySettingProvider>();
}

But this no work! What is correct appropoach to do it ? Thnaks !

Showing 1 to 10 of 13 entries