Moving/Replacing entries with Gldapo 0.7

Following on from the previous post, Gldapo 0.7 makes dealing with the location of LDAP objects much easier. This impacts the move() and replace() methods. I'll focus on replace() here, but pretty much everything applies to move().

0.7 introduces a new signature of replace(String namingValue, Object parent). Let's look at some usage then I'll explain.

What we want to do here is replace an object with cn=Luke and sn=Daily with an object with sn=Daley (note: we could do this with a search, mod, save admittedly, but this is just an example).

I am using the person schema class from the previous post.

First, 0.6 style…

def p = new Person(
    cn: "Luke",
    sn: "Daley"
)
 
p.replace("cn=Luke")

In 0.7…

def p = new Person(
    sn: "Daley"
)
 
p.replace("Luke", null)

Or…

def p = new Person(
    cn: "Luke",
    sn: "Daley"
)
 
p.replace()

Because we now know which attribute defines the name, we don't need to duplicate that information in the replace() call.

The second argument to replace(String,Object) is the parent of the object to replace. Say we wanted to replace an object in a different ou…

p.replace("Luke", "ou=people")

The move(String,Object) method follows similar semantics. Note though that there is no move() method, cause that just wouldn't make sense.

07:30 PM | 4 Comments | Tags:

Comments

  1. wcbgvgjz wcbgvgjz

    Delete Edit wcbgvgjz on
  2. rzuziubp rzuziubp

    Delete Edit rzuziubp on
  3. oajduiko oajduiko

    Delete Edit oajduiko on
  4. hey not bad...

    Delete Edit free DDL on