UniStuttgart-VISUS / Visus.LdapAuthentication

LDAP authentication middleware for ASP.NET Core
MIT License
24 stars 8 forks source link

Override LdapUserBase "Property set method not found" #1

Closed antoniolago closed 1 year ago

antoniolago commented 1 year ago

Hello, while trying to override LdapUserBase like documented:

  public sealed class CustomLdapUser : LdapUserBase
  {
      [LdapAttribute(Schema.ActiveDirectory, "displayName")]
      [Claim(CustomClaimTypes.Nome)]
      public override string DisplayName => base.DisplayName;  
   }

I get:

  {"Property set method not found."}
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at Visus.LdapAuthentication.LdapUserBase.Assign(LdapEntry entry, LdapConnection connection, ILdapOptions options)
   at Visus.LdapAuthentication.LdapAuthenticationService`1.Login(String username, String password)

I'm currently using

  [LdapAttribute(Schema.ActiveDirectory, "displayName")]
  [Claim(CustomClaimTypes.Nome)]
  public string DisplayName { get; internal set; }

This correctly maps the claims I want but obviously I'm not able to properly access the property ldapUser.DisplayName (it's value is null)

crowbar27 commented 1 year ago

I was able to repro the issue and searching for a fix.

crowbar27 commented 1 year ago

Fixed in Nuget package 1.9.0