Modifying objectClass

May 12, 2014 at 3:55 AM
Hello,

I have two classes: User (top, gosaAccount) and subclass of User - MailUser(top, gosaAccount, gosaMailAccount). Can I update User to MailUser thru class mapping?

Or it can only be done via attribute modification?
Coordinator
May 14, 2014 at 1:02 AM
Yes, you can by using SubClassMap.
May 14, 2014 at 3:48 AM
Edited May 14, 2014 at 3:48 AM
No, I mean I have subclasses.
[DirectorySchema("ou=people,dc=example,dc=org", ObjectClasses = new string[] { "top", "person", "organizationalPerson", "inetOrgPerson", "gosaAccount" })]
public class User : DirectoryObjectBase {
...
}

[DirectorySchema("ou=Komandor,dc=sm-komandor,dc=ru", ObjectClasses = new string[] { "top", "person", "organizationalPerson", "inetOrgPerson", "gosaAccount", "gosaMailAccount" })]
public class MailUser : LdapUser
{
...
}

public class Worker {
  private LdapContext context;

  public void DoWork() {
    var user = context.Users.Where(x => x.Uid == "testuser").FirstOrDefault();

    if (user != null && !(user instanceof MailUser)) {    
      // Can I upgrade "user" to "MailUser" via class mapping?
    }
  }
}

Coordinator
May 14, 2014 at 5:51 AM
Ah, I see. Currently if you query for User objects then everything will come back as a User object. I can look at including support for using discriminators based on objectclass.

Would something like this work?
[DirectorySchema("...", ObjectClasses = ...)]
public class User : DirectoryObjectBase {
...
}

[DirectorySchema("...", DiscriminatorClass = "gosaMailAccount", ObjectClasses = ...)]
public class MailUser : LdapUser
{
...
}
Coordinator
May 16, 2014 at 4:41 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.