4.6. Command-line interface for domain management#
udm is the command-line interface for domain management in Univention Directory Manager (UDM). Use it to automate administrative tasks in scripts and to integrate domain management into other programs. It’s an alternative to the web-based Management UI and its management modules.
Run the command as the root user on the Primary Directory Node
with the univention-directory-manager command,
or use the short form udm.
UDM and the web interface use the same domain management modules. As a result, the command-line interface provides the same functions as the web interface.
See also
- Management module reference
in Nubus Manual 1.x [4] for the reference to the web-based management modules of UDM in the Management UI.
4.6.1. Parameters of the command-line interface#
To list all available modules,
run the command shown in Listing 4.17
with the modules parameter.
$ univention-directory-manager modules
Available Modules are:
computers/computer
computers/domaincontroller_backup
computers/domaincontroller_master
computers/domaincontroller_slave
[...]
Every module has the following operations:
- list, lookup#
Lists all existing objects of this type.
- create, new#
Creates a new object.
- modify, edit#
Modifies an existing object.
- remove, delete#
Deletes an object.
- move#
Moves an object to another position in the LDAP directory.
- restore#
Restores an object from the Recycle Bin.
To view the options and operations for a UDM module, run the command shown in Listing 4.18 with the module name and the operation.
$ univention-directory-manager users/user move
[...]
general options:
--binddn bind DN
--bindpwd bind password (deprecated, use --bindpwdfile instead)
--bindpwdfile file containing bind password
[...]
create options:
--position Set position in tree
--set Set variable to value, e.g. foo=bar
[...]
modify options:
--dn Edit object with DN
--set Set variable to value, e.g. foo=bar
[...]
remove options:
--dn Remove object with DN
--superordinate Use superordinate module
[...]
list options:
--filter Lookup filter
--position Search underneath of position in tree
[...]
move options:
--dn Move object with DN
--position Move to position in tree
[...]
To view all operations, options, and attributes for a module,
run the command shown in Listing 4.19.
Replace category/modulename with the module path,
for example, users/user.
$ univention-directory-manager [category/modulename]
When using the udm create operation,
you must specify all attributes marked with *.
Some attributes can have more than one value,
for example, email addresses for user objects.
The [] marker after an attribute name identifies a multi-value field.
Some attributes require specific options for the object.
To set an option for an individual attribute,
enter the option name,
as shown in Listing 4.20.
users/user variables:
General:
username (*) Username
[...]
Contact:
e-mail (person,[]) E-Mail Address
Here, username (*) means that you must always set this attribute
when you create user objects.
When you enable the person option for the user account,
which is the default,
you can add one or more email addresses to the contact information.
The following common parameters are available, depending on the operation:
- --binddn#
Use this parameter to specify the bind DN for the LDAP connection.
Important
You usually don’t need
--binddnwhen you run udm asrooton a Nubus for UCS system. In that case, UDM tries to use local system credentials automatically.Provide
--binddnwhen you want to authenticate as a different LDAP account or when the default local credentials aren’t available or don’t have the required permissions.
- --bindpwd#
Use this parameter to specify the bind password for the LDAP connection.
Deprecated since version 5.2-4:
--bindpwdis deprecated. Use--bindpwdfileinstead.
- --bindpwdfile#
Use this parameter to specify a file that contains the bind password for
--binddn.Important
You usually don’t need
--bindpwdfilewhen you run udm asrooton a UCS system. If you don’t enter bind credentials, UDM tries to use local system credentials, such as the administrator account or the machine account.Provide
--bindpwdfiletogether with--binddnwhen you want to authenticate explicitly or when automatic local authentication isn’t available.
- --logfile#
Use this parameter to specify the path of the log file for the command. If you don’t enter
--logfile, UDM writes to/var/log/univention/directory-manager-cmd.log.
- --tls#
Use this parameter to control StartTLS for the LDAP connection.
0Don’t use StartTLS.
1Try StartTLS.
2Require StartTLS. This is default behavior, if you don’t provide
--tls.
- --dn#
Use this parameter to specify the distinguished name (DN) of the object when you modify, delete, move, or restore it. Enter the complete DN, as shown in Listing 4.21.
$ univention-directory-manager users/user remove \ --dn "uid=ldapadmin,cn=users,dc=company,dc=example"
- --position#
Use this parameter to specify an LDAP position.
In the
udm createoperation, this parameter specifies where UDM creates the object. If you don’t enter--position, UDM creates the object under the module’s default LDAP base. If you use--superordinatewithout--position, UDM uses the superordinate DN as the position.In the
udm listoperation, this parameter limits the search to objects below the specified LDAP position.In the
udm moveoperation, this parameter specifies the target position, as shown in Listing 4.22.$ univention-directory-manager computers/ipmanagedclient move \ --dn "cn=desk01,cn=management,cn=computers,dc=company,dc=com" \ --position "cn=finance,cn=computers,dc=company,dc=example"
- --set#
Use this parameter to assign the given value to the following attribute. Use one
--setparameter for each attribute-value pair, as shown in Listing 4.23.$ univention-directory-manager users/user create \ --position "cn=users,dc=company,dc=example" \ --set username="jsmith" \ --set firstname="John" \ --set lastname="Smith" \ --set password="12345678"
- --append, --remove#
Use
--appendor--removeto add or remove a value from a multi-value field, as shown in Listing 4.24.$ univention-directory-manager groups/group modify \ --dn "cn=staff,cn=groups,dc=company,dc=example" \ --append users="uid=smith,cn=users,dc=company,dc=example" \ --remove users="uid=miller,cn=users,dc=company,dc=example"
- --option#
Use this parameter to define the LDAP object classes for an object. For example, if you provide only the
pkioption for a user object, you can’t specifymailPrimaryAddressbecause this attribute belongs to themailoption.
- --append-option, --remove-option#
Use
--append-optionto add a module option to the current option set.Use
--remove-optionto remove a module option from the current option set.These parameters are useful when a module provides default options, and you want to adjust them for one command.
- --superordinate#
Use
--superordinatewhen an object requires the DN of a parent object. For example, a DHCP object requires a DHCP service object. Pass the DN of that object with the--superordinateoption.For list operations, you can also use
--superordinateto limit the lookup context for dependent objects.
- --policy-reference#
Use the
--policy-referenceparameter to assign a policy to an object. If you link a policy to an object, the object uses the policy settings, as shown in Listing 4.25. Replacecategory/modulenamewith the module path, and replaceOperationwith the operation that you want to run.Repeat the parameter to assign more than one policy.
$ univention-directory-manager [category/modulename] [Operation] \ --policy-reference "cn=sales,cn=pwhistory,cn=users,cn=policies,dc=company,dc=example"
- --policy-dereference#
Use the
--policy-dereferenceparameter to remove a policy from an object.Repeat the parameter to remove more than one policy reference.
- --ignore_exists#
The
--ignore_existsparameter skips existing objects. If the object already exists, UDM still returns the error code0for no error.
- --ignore_not_exists#
Use this parameter with the
udm modifyorudm removeoperation to ignore missing objects. If the object doesn’t exist, UDM doesn’t report an error.
- --remove_referring#
Use this parameter with the
udm removeoperation to remove referring objects during cleanup, if the module supports that cleanup.
- --filter#
Use this parameter to select objects with an LDAP filter.
With the
udm listoperation, UDM lists matching objects.With the
udm removeoperation, UDM removes the matching object in the selected context. You can combine--filterwith--dnor--position.
4.6.2. Command-line interface examples#
Use these examples as templates for your own scripts.
4.6.2.1. Users#
This section lists examples of the udm working with the Users module.
To create a user in the standard user container, run the
udm createcommand shown in Listing 4.26.$ univention-directory-manager users/user create \ --position "cn=users,dc=example,dc=com" \ --set username="user01" \ --set firstname="Random" \ --set lastname="User" \ --set organisation="Example company LLC" \ --set mailPrimaryAddress="mail@example.com" \ --set password="secretpassword"
To add a postal address for an existing user, run the
udm modifycommand shown in Listing 4.27.$ univention-directory-manager users/user modify \ --dn "uid=user01,cn=users,dc=example,dc=com" \ --set street="Exemplary Road 42" \ --set postcode="28239" \ --set city="Bremen"
To list all users whose username begins with
user, run theudm listcommand shown in Listing 4.28.$ univention-directory-manager users/user list \ --filter uid='user*'
To limit the search to a specific LDAP position, run the
udm listcommand shown in Listing 4.29. This example lists all users in thecn=bremen,cn=users,dc=example,dc=comcontainer.$ univention-directory-manager users/user list \ --filter uid="user*" \ --position "cn=bremen,cn=users,dc=example,dc=com"
To remove the user
user04, run theudm removecommand shown in Listing 4.30.$ univention-directory-manager users/user remove \ --dn "uid=user04,cn=users,dc=example,dc=com"
If your organization has two sites with separate containers, you can move a user from the
Hamburgcontainer to theBremencontainer. Run theudm movecommand shown in Listing 4.31.$ univention-directory-manager users/user move \ --dn "uid=user03,cn=hamburg,cn=users,dc=example,dc=com" \ --position "cn=bremen,cn=users,dc=example,dc=com"
See also
- Users module
in Nubus Manual 1.x [4] for information about the Users management module.
4.6.2.2. Groups#
This section lists examples of the udm working with the Groups module.
To create the group
Example Usersand add the useruser01, run theudm createcommand shown in Listing 4.32.$ univention-directory-manager groups/group create \ --position "cn=groups,dc=example,dc=com" \ --set name="Example Users" \ --set users="uid=user01,cn=users,dc=example,dc=com"
To add the user
user02to the existing group, run theudm modifycommand shown in Listing 4.33.$ univention-directory-manager groups/group modify \ --dn "cn=Example Users,cn=groups,dc=example,dc=com" \ --append users="uid=user02,cn=users,dc=example,dc=com"
Caution
A
--seton the attributeusersoverwrites the list of group members in contrast to--append.To remove the user
user01from the group, run theudm modifycommand shown in Listing 4.34.$ univention-directory-manager groups/group modify \ --dn "cn=Example Users,cn=groups,dc=example,dc=com" \ --remove users="uid=user01,cn=users,dc=example,dc=com"
See also
- Groups module
in Nubus Manual 1.x [4] for information about the Groups management module.
4.6.2.3. Containers#
To create the cn=Bremen container under cn=computers
for computers at the Bremen site,
run the udm create command shown in Listing 4.35.
The computerPath option also registers this container
as the standard container for computer objects.
For more information, see User-defined LDAP structures
in Nubus Manual 1.x [4].
$ univention-directory-manager container/cn create \
--position "cn=computers,dc=example,dc=com" \
--set name="bremen" \
--set computerPath=1
See also
- LDAP directory module
in Nubus Manual 1.x [4] for information about the LDAP directory management module.
4.6.2.4. Policies#
This section lists examples of the udm working with the Policies module.
To create a user quota policy, run the
udm createcommand shown in Listing 4.36.$ univention-directory-manager policies/share_userquota create \ --position "cn=policies,dc=example,dc=com" \ --set name="Default quota" \ --set softLimitSpace=5GB \ --set hardLimitSpace=10GB
To link this policy to the user container
cn=users, run theudm modifycommand shown in Listing 4.37.$ univention-directory-manager container/cn modify \ --dn "cn=users,dc=example,dc=com" \ --policy-reference "cn=Default quota,cn=policies,dc=example,dc=com"
To create a Univention Configuration Registry policy that sets the storage time for log files to one year, run the
udm createcommand shown in Listing 4.38. Use one space to separate the variable name from its value.$ univention-directory-manager policies/registry create \ --position "cn=config-registry,cn=policies,dc=example,dc=com" \ --set name="default UCR settings" \ --set registry="logrotate/rotate/count 52"
To add another value to the UCR policy, run the
udm modifycommand shown in Listing 4.39.$ univention-directory-manager policies/registry modify \ --dn "cn=default UCR settings,cn=config-registry,cn=policies,dc=example,dc=com" \ --append registry='"logrotate/compress" "no"'
See also
- Policies module
in Nubus Manual 1.x [4] for information about the Policies management module.
4.6.2.5. Computers#
To create a Windows client account,
run the udm create command shown in Listing 4.40.
If the client joins the Samba domain later,
as described in Windows domain joins,
the domain join uses this computer account automatically:
$ univention-directory-manager computers/windows create \
--position "cn=computers,dc=example,dc=com" \
--set name=WinClient01 \
--set mac=aa:bb:cc:aa:bb:cc \
--set ip=192.0.2.10
See also
- Computers module
in Nubus Manual 1.x [4] for information about the Computers management module.
4.6.2.7. Printers#
To create the printer share LaserPrinter01 on the print server
printserver.example.com,
run the udm create command shown in Listing 4.42.
The PPD file defines the printer properties.
Specify the PPD filename relative to /usr/share/ppd/.
Ensure the printer is reachable over the network and supports the IPP protocol.
Note
Include a blank space between the print protocol
and the target path in the uri parameter.
For a list of print protocols,
see Protocol and Destination
in Nubus Manual 1.x [4].
You can group printers in a printer group to streamline administration.
For more information about printer groups,
see Printer groups.
Before creating a printer group,
ensure the printer shares you want to add already exist.
To create a printer group,
run the udm create command shown in Listing 4.43.
$ univention-directory-manager shares/printergroup create \
--position "cn=printers,dc=example,dc=com" \
--set name=LaserPrinters \
--set spoolHost="printserver.example.com" \
--append groupMember=LaserPrinter01 \
--append groupMember=LaserPrinter02
See also
- Printers module
in Nubus Manual 1.x [4] for information about the Printers management module.
4.6.2.8. DNS and DHCP#
To configure an IP assignment through DHCP, register a DHCP computer entry for the MAC address, as shown in Listing 4.44. For more information about DHCP, see IP assignment via DHCP.
$ univention-directory-manager dhcp/host create \
--superordinate "cn=example.com,cn=dhcp,dc=example,dc=com" \
--set host="Client222" \
--set fixedaddress="192.0.2.110" \
--set hwaddress="ethernet 00:11:22:33:44:55"
To resolve a computer name through DNS, use the commands shown in Listing 4.45 and Listing 4.46 to configure forward resolution with a host record and reverse resolution with a PTR record. For more information about DNS, see Administration of DNS data with BIND.
$ univention-directory-manager dns/host_record create \
--superordinate "zoneName=example.com,cn=dns,dc=example,dc=com" \
--set name="Client222" \
--set a="192.0.2.110"
$ univention-directory-manager dns/ptr_record create \
--superordinate "zoneName=0.168.192.in-addr.arpa,cn=dns,dc=example,dc=com" \
--set address="110" \
--set ptr_record="Client222.example.com."
See also
- DHCP module
in Nubus Manual 1.x [4] for information about the DHCP management module.
- DNS module
in Nubus Manual 1.x [4] for information about the DNS management module.
4.6.2.9. Extended attributes#
Use extended attributes to add fields to management modules in the Management UI.
For more information, see Expand management modules.
To add a new attribute that stores the license plate number of a company car for each user,
run the udm create command shown in Listing 4.47.
The object class univentionFreeAttributes stores these values.
$ univention-directory-manager settings/extended_attribute create \
--position "cn=custom attributes,cn=univention,dc=example,dc=com" \
--set name="CarLicense" \
--set module="users/user" \
--set ldapMapping="univentionFreeAttribute1" \
--set objectClass="univentionFreeAttributes" \
--set longDescription="License plate number of the company car" \
--set tabName="Company car" \
--set multivalue=0 \
--set syntax="string" \
--set shortDescription="Car license"
See also
- Expand management modules
in Nubus Manual 1.x [4] for information about how to expand management modules.