<?xml version="1.0" encoding="UTF-8"?>
|
<!--
|
! CCPL HEADER START
|
!
|
! This work is licensed under the Creative Commons
|
! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
|
! To view a copy of this license, visit
|
! http://creativecommons.org/licenses/by-nc-nd/3.0/
|
! or send a letter to Creative Commons, 444 Castro Street,
|
! Suite 900, Mountain View, California, 94041, USA.
|
!
|
! You can also obtain a copy of the license at
|
! trunk/opendj/legal-notices/CC-BY-NC-ND.txt.
|
! See the License for the specific language governing permissions
|
! and limitations under the License.
|
!
|
! If applicable, add the following below this CCPL HEADER, with the fields
|
! enclosed by brackets "[]" replaced with your own identifying information:
|
! Portions Copyright [yyyy] [name of copyright owner]
|
!
|
! CCPL 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 ]] && 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 <<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>
|