Problem: UMC Complains About Missing Defaults

python
umc
problem

#1

Problem

Univention Management Console (UMC) complains about missing default values and informs to set them as shown in the following screenshot:
screenshot_2018-11-27_094750

The following empty properties were set to default values in the form. 
These values will be applied when saving.
* Account .....

Solution

Create and execute the following Python script. It will set all empty attributes to the default values; this can be done for users as well as for groups and computers.

Users

#!/usr/bin/python2
import univention.admin.modules as modules
from univention.admin.uldap import getAdminConnection

FILTER_STRING = ''

modules.update()
lo,po=getAdminConnection()
user_mod = modules.get('users/user')
modules.init(lo,po,user_mod)


users = user_mod.lookup(None, lo, FILTER_STRING)

for user in users:
	user.open()
	print("Setting default values for user '{}'".format(user['username']))
	user.set_defaults = 1
	user.set_default_values()
	user.modify()

Groups

You can do this similar with groups

#!/usr/bin/python2
import univention.admin.modules as modules
from univention.admin.uldap import getAdminConnection

FILTER_STRING = ''

modules.update()
lo,po=getAdminConnection()
group_mod = modules.get('groups/group')
modules.init(lo,po,group_mod)


groups = group_mod.lookup(None, lo, FILTER_STRING)

for group in groups:
	group.open()
	print("Setting default values for group '{}'".format(group['name']))
	group.set_defaults = 1
	group.set_default_values()
	group.modify()

Computers

The following snippet sets the default values only for windows computers (computers/windows). Its also possible to replace the UDM windows computer module name with another UDM computer module, e.g. computers/linux.

#!/usr/bin/python2
import univention.admin.modules as modules
from univention.admin.uldap import getAdminConnection

FILTER_STRING = ''

modules.update()
lo, po = getAdminConnection()
computer_mod = modules.get('computers/windows')
modules.init(lo, po, computer_mod)


computers = computer_mod.lookup(None, lo, FILTER_STRING)

for computer in computers:
        computer.open()
        print("Setting default values for computer '{}'".format(computer['name']))
        computer.set_defaults = 1
        computer.set_default_values()
        computer.modify()

Problem: permissionDenied reject on a school slave