/usr/lib/python3/dist-packages/lib389/suffix.py is in python3-lib389 1.3.7.10-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | # --- BEGIN COPYRIGHT BLOCK ---
# Copyright (C) 2015 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
from lib389 import DirSrv, InvalidArgumentError
from lib389.properties import *
class Suffix(object):
proxied_methods = 'search_s getEntry'.split()
def __init__(self, conn):
"""@param conn - a DirSrv instance"""
self.conn = conn
self.log = conn.log
def __getattr__(self, name):
if name in Suffix.proxied_methods:
return DirSrv.__getattr__(self.conn, name)
def list(self):
'''
Returns the list of suffixes DN for which it exists a mapping tree
entry
@param None
@return list of suffix DN
@raise None
'''
suffixes = []
ents = self.conn.mappingtree.list()
for ent in ents:
vals = self.conn.mappingtree.toSuffix(entry=ent)
suffixes.append(vals[0])
return suffixes
def toBackend(self, suffix=None):
'''
Returns the backend entry that stores the provided suffix
@param suffix - suffix DN of the backend
@return backend - LDAP entry of the backend
@return ValueError - if suffix is not provided
'''
if not suffix:
raise ValueError("suffix is mandatory")
return self.conn.backend.list(suffix=suffix)
def getParent(self, suffix=None):
'''
Returns the DN of a suffix that is the parent of the provided
'suffix'.
If 'suffix' has no parent, it returns None
@param suffix - suffix DN of the backend
@return parent suffix DN
@return ValueError - if suffix is not provided
InvalidArgumentError - if suffix is not implemented on the
server
'''
if not suffix:
raise ValueError("suffix is mandatory")
ents = self.conn.mappingtree.list(suffix=suffix)
if len(ents) == 0:
raise InvalidArgumentError(
"suffix %s is not implemented on that server" % suffix)
mapping_tree = ents[0]
if mapping_tree.hasValue(MT_PROPNAME_TO_ATTRNAME[MT_PARENT_SUFFIX]):
return mapping_tree.getValue(
MT_PROPNAME_TO_ATTRNAME[MT_PARENT_SUFFIX])
else:
return None
raise NotImplemented
def setProperties(self, suffix):
'''
Supported properties:
'''
if not suffix:
raise ValueError("suffix is mandatory")
|