1

We're developing a portal where administrators can manage user and group object in Active Directory without having access to the server itself.

Whenever a user is locked out by policies, updating the user will always unlock the user even though we didn't update the lockoutTime attribute

Here's the ClassMap we use for LINQ to LDAP

 public override IClassMap PerformMapping(string namingContext = null, string objectCategory = null, bool includeObjectCategory = true, IEnumerable<string> objectClasses = null, bool includeObjectClasses = true)
    {
        NamingContext(namingContext);

        ADUserEntity.SetNamingContext(namingContext);

        ObjectCategory("Person");
        ObjectClass("User");

        DistinguishedName(x => x.DistinguishedName);
        Map(x => x.Name).Named(Identity.cn).ReadOnly();
        Map(x => x.Department).Named(Identity.department);
        Map(x => x.Id).Named(Identity.objectGUID).StoreGenerated();
        Map(x => x.Title).Named(Identity.title);
        Map(x => x.GivenName).Named(Identity.givenName);

        Map(x => x.SurName).Named(Identity.sn);
        Map(x => x.MiddleName).Named(Identity.middleName);
        Map(x => x.SAMAccountName).Named(Identity.sAMAccountName);

        Map(x => x.AccountControl).Named(Identity.userAccountControl);
        Map(x => x.DisplayName).Named(Identity.displayName);

        Map(x => x.TelephoneNumber).Named(Identity.telephoneNumber);
        Map(x => x.MemberOf).Named(Identity.memberof);
        Map(x => x.LockoutTime).Named(Identity.lockoutTime).ReadOnly();
        Map(x => x.LastLogon).Named(Identity.lastLogon).ReadOnly();
        Map(x => x.EmailAddress).Named(Identity.mail).ReadOnly();
        Map(x => x.PwdLastSet).Named(Identity.pwdLastSet).ReadOnly();

        Map(x => x.UserPrincipalName).Named(Identity.userPrincipalName);

        return this;
    }

LockoutTime has a simple getter/setter

    ...

    public override long? LockoutTime
    {
        get
        {
            return _userEntity.LockoutTime;
        }

        set
        {
            _userEntity.LockoutTime = value;
        }
    }
    ...

I have tried removing the .ReadOnly() property on the LockoutTime mapping, which results in an Exception thrown in LINQ to LDAP, which in turn is caused by an error message thrown by the Active Directory Server (Windows Server 2012 R2).

PBX_g33k
  • 851
  • 1
  • 6
  • 12

0 Answers0