@GldapoNamingAttribute

I've been working on making the way you define the location of an entry object better.

In Gldapo 0.6, this is a bit cumbersome. Let's look at some examples. Here is our schema class in 0.6…

class Person
{
    String cn
    String sn
}

So let's create one of these people in an ou called people

def p = new Person(
    cn: "Luke"
    sn: "Daley"
    rdn: "cn=Luke,ou=people"
)
p.save()

Obviously, that could be better.

Let's take a look at how this has improved. First of all our schema class redone…

class Person
{
    @GldapoNamingAttribute
    String cn
    String sn
}

And the same create…

def p = new Person(
    cn: "Luke"
    sn: "Daley"
    parent: "ou=people"
)
p.save()

So what has happened?

The @GldapoNamingAttribute annotation

In 0.7, all schema classes must annotate one attribute with @GldapoNamingAttribute. It is a bit of an inconvenience if you never really care about where the object is (say if you are just using Gldapo for authentication), but it does weigh in with significant advantages.

The parent property

The parent property is new in 0.7. It returns a DistinguishedName that is the entry above the entry, relative to the entry's directory.

So the primary way to set an entry's location is to use a combination of setting the objects naming attribute and the parent attribute.

Using rdn

The rdn attribute still exists (though it's name may change before release) and is even improved. You could also create the person like this…

def p = new Person(
    sn: "Daley"
    rdn: "cn=Luke,ou=people"
)
p.save()

That will work just fine. The rdn property is also gettable on objects that were defined using a naming attribute value and a parent.

You must however match the naming attributes. For example, this won't work…

def p = new Person(
    sn: "Daley"
    rdn: "uid=Luke,ou=people"
)
p.save()

This will complain about trying to set a naming attribute called uid, when cn is defined as the attribute.

Note: All these examples assume only one directory is defined, therefore there is no need to specify which directory the entry belongs to when creating.

The current snapshot of Gldapo has this new feature.

11:16 PM | 2 Comments | Tags:

Comments

  1. dupa irqzwrug

    Delete Edit irqzwrug on
  2. snhbcsqr snhbcsqr

    Delete Edit snhbcsqr on