ldapmodify-examples.xml revision 73adb2e3dbaa8a9f6448cefccb7933f68c3c7348
<?xml version="1.0" encoding="UTF-8"?>
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
! or http://forgerock.org/license/CDDLv1.0.html.
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at legal-notices/CDDLv1_0.txt.
! If applicable, add the following below this CDDL HEADER, with the
! fields enclosed by brackets "[]" replaced with your own identifying
! information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2015 ForgeRock AS.
!
-->
<refsect1 xmlns="http://docbook.org/ns/docbook"
version="5.0" xml:lang="en"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://docbook.org/ns/docbook
http://docbook.org/xml/5.0/xsd/docbook.xsd">
<title>Examples</title>
<para>
The following example demonstrates use of the command
to add an entry to the directory.
</para>
<screen>
$ <userinput>cat newuser.ldif</userinput>
<computeroutput>dn: uid=newuser,ou=People,dc=example,dc=com
uid: newuser
facsimileTelephoneNumber: +1 408 555 1213
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
givenName: New
cn: New User
cn: Real Name
telephoneNumber: +1 408 555 1212
sn: Jensen
roomNumber: 1234
homeDirectory: /home/newuser
uidNumber: 10389
mail: newuser@example.com
l: South Pole
ou: Product Development
ou: People
gidNumber: 10636</computeroutput>
$ <userinput>ldapmodify -p 1389 -a -f newuser.ldif \
-D uid=kvaughan,ou=people,dc=example,dc=com -w bribery</userinput>
<computeroutput>Processing ADD request for uid=newuser,ou=People,dc=example,dc=com
ADD operation successful for DN uid=newuser,ou=People,dc=example,dc=com</computeroutput>
</screen>
<para>
The following listing shows a UNIX shell script that adds a user entry.
</para>
<programlisting language="shell">
#!/bin/sh
#
# Add a new user with the ldapmodify utility.
#
usage(){
echo "Usage: $0 uid firstname lastname"
exit 1
}
[[ $# -lt 3 ]] &amp;&amp; usage
LDAPMODIFY=/path/to/opendj/bin/ldapmodify
HOST=opendj.example.com
PORT=1389
ADMIN=uid=kvaughan,ou=people,dc=example,dc=com
PWD=bribery
$LDAPMODIFY -h $HOST -p $PORT -D $ADMIN -w $PWD -a &lt;&lt;EOF
dn: uid=$1,ou=people,dc=example,dc=com
uid: $1
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: $2 $3
givenName: $2
sn: $3
mail: $1@example.com
EOF
</programlisting>
<para>
The following example demonstrates adding a Description attribute
to the new user's entry.
</para>
<screen>
$ <userinput>cat newdesc.ldif</userinput>
<computeroutput>dn: uid=newuser,ou=People,dc=example,dc=com
changetype: modify
add: description
description: A new user's entry</computeroutput>
$ <userinput>ldapmodify -p 1389 -f newdesc.ldif \
-D uid=kvaughan,ou=people,dc=example,dc=com -w bribery</userinput>
<computeroutput>Processing MODIFY request for uid=newuser,ou=People,dc=example,dc=com
MODIFY operation successful for DN uid=newuser,ou=People,dc=example,dc=com</computeroutput>
</screen>
<para>
The following example demonstrates changing the Description attribute
for the new user's entry.
</para>
<screen>
$ <userinput>cat moddesc.ldif</userinput>
<computeroutput>dn: uid=newuser,ou=People,dc=example,dc=com
changetype: modify
replace: description
description: Another description</computeroutput>
$ <userinput>ldapmodify -p 1389 -f moddesc.ldif \
-D uid=kvaughan,ou=people,dc=example,dc=com -w bribery</userinput>
<computeroutput>Processing MODIFY request for uid=newuser,ou=People,dc=example,dc=com
MODIFY operation successful for DN uid=newuser,ou=People,dc=example,dc=com</computeroutput>
</screen>
<para>
The following example demonstrates deleting the new user's entry.
</para>
<screen>
$ <userinput>cat deluser.ldif</userinput>
<computeroutput>dn: uid=newuser,ou=People,dc=example,dc=com
changetype: delete</computeroutput>
$ <userinput>ldapmodify -p 1389 -f deluser.ldif \
-D uid=kvaughan,ou=people,dc=example,dc=com -w bribery</userinput>
<computeroutput>Processing DELETE request for uid=newuser,ou=People,dc=example,dc=com
DELETE operation successful for DN uid=newuser,ou=People,dc=example,dc=com</computeroutput>
</screen>
</refsect1>