2007-08-06 09:05:53 -05:00
|
|
|
# Authors: Rob Crittenden <rcritten@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
2008-02-04 14:15:52 -06:00
|
|
|
# published by the Free Software Foundation; version 2 only
|
2007-08-06 09:05:53 -05:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
import ipa.rpcclient as rpcclient
|
2007-10-09 11:26:16 -05:00
|
|
|
import entity
|
2007-08-06 09:05:53 -05:00
|
|
|
import user
|
2007-08-24 14:42:56 -05:00
|
|
|
import group
|
2007-11-26 10:12:58 -06:00
|
|
|
import radius_util
|
2007-08-06 09:05:53 -05:00
|
|
|
|
|
|
|
class IPAClient:
|
|
|
|
|
2008-04-24 09:25:30 -05:00
|
|
|
def __init__(self,transport=None,verbose=False):
|
0000-12-31 18:09:24 -05:50
|
|
|
if transport:
|
|
|
|
self.local = True
|
|
|
|
self.transport = transport
|
2007-08-06 09:05:53 -05:00
|
|
|
else:
|
0000-12-31 18:09:24 -05:50
|
|
|
self.local = False
|
2008-04-24 09:25:30 -05:00
|
|
|
self.transport = rpcclient.RPCClient(verbose)
|
2007-08-06 09:05:53 -05:00
|
|
|
|
|
|
|
def set_principal(self,princ):
|
2007-08-17 09:03:33 -05:00
|
|
|
"""Set the name of the principal that will be used for
|
|
|
|
LDAP proxy authentication"""
|
2007-08-06 09:05:53 -05:00
|
|
|
if self.local:
|
|
|
|
self.transport.set_principal(princ)
|
|
|
|
|
2007-09-14 16:19:02 -05:00
|
|
|
def set_krbccache(self,krbccache):
|
|
|
|
"""Set the file location of the Kerberos credentials cache to be used
|
|
|
|
for LDAP authentication"""
|
|
|
|
if self.local:
|
|
|
|
self.transport.set_krbccache(krbccache)
|
|
|
|
|
2007-10-12 17:11:55 -05:00
|
|
|
# Higher-level API
|
|
|
|
|
|
|
|
def get_aci_entry(self, sattrs=None):
|
|
|
|
"""Returns the entry containing access control ACIs."""
|
|
|
|
|
|
|
|
result = self.transport.get_aci_entry(sattrs)
|
|
|
|
return entity.Entity(result)
|
|
|
|
|
2007-10-09 11:26:16 -05:00
|
|
|
# General searches
|
|
|
|
|
|
|
|
def get_entry_by_dn(self,dn,sattrs=None):
|
|
|
|
"""Get a specific entry by dn. If sattrs is set then only those
|
|
|
|
attributes will be returned, otherwise all available attributes
|
|
|
|
are returned."""
|
|
|
|
result = self.transport.get_entry_by_dn(dn,sattrs)
|
|
|
|
return entity.Entity(result)
|
|
|
|
|
|
|
|
def get_entry_by_cn(self,cn,sattrs=None):
|
|
|
|
"""Get a specific entry by cn. If sattrs is set then only those
|
|
|
|
attributes will be returned, otherwise all available attributes
|
|
|
|
are returned."""
|
|
|
|
result = self.transport.get_entry_by_cn(cn,sattrs)
|
|
|
|
return entity.Entity(result)
|
|
|
|
|
2007-10-15 11:04:13 -05:00
|
|
|
def update_entry(self,entry):
|
|
|
|
"""Update a entry."""
|
|
|
|
|
|
|
|
result = self.transport.update_entry(entry.origDataDict(), entry.toDict())
|
|
|
|
return result
|
|
|
|
|
2007-08-24 14:42:56 -05:00
|
|
|
# User support
|
2007-08-23 08:44:00 -05:00
|
|
|
def get_user_by_uid(self,uid,sattrs=None):
|
2007-08-17 09:03:33 -05:00
|
|
|
"""Get a specific user by uid. If sattrs is set then only those
|
2007-08-24 14:42:56 -05:00
|
|
|
attributes will be returned, otherwise all available attributes
|
|
|
|
are returned."""
|
2007-08-23 08:44:00 -05:00
|
|
|
result = self.transport.get_user_by_uid(uid,sattrs)
|
2007-08-06 09:05:53 -05:00
|
|
|
return user.User(result)
|
|
|
|
|
2007-10-01 16:33:16 -05:00
|
|
|
def get_user_by_principal(self,principal,sattrs=None):
|
|
|
|
"""Get a specific user by uid. If sattrs is set then only those
|
|
|
|
attributes will be returned, otherwise all available attributes
|
|
|
|
are returned."""
|
|
|
|
result = self.transport.get_user_by_principal(principal,sattrs)
|
|
|
|
return user.User(result)
|
|
|
|
|
2007-10-18 16:33:55 -05:00
|
|
|
def get_user_by_email(self,email,sattrs=None):
|
|
|
|
"""Get a specific user's entry. Return as a dict of values.
|
|
|
|
Multi-valued fields are represented as lists.
|
|
|
|
"""
|
|
|
|
result = self.transport.get_user_by_email(email,sattrs)
|
|
|
|
return user.User(result)
|
|
|
|
|
2007-09-25 17:44:49 -05:00
|
|
|
def get_users_by_manager(self,manager_dn,sattrs=None):
|
|
|
|
"""Gets the users the report to a particular manager.
|
|
|
|
If sattrs is not None then only those
|
|
|
|
attributes will be returned, otherwise all available
|
|
|
|
attributes are returned. The result is a list of groups."""
|
|
|
|
results = self.transport.get_users_by_manager(manager_dn, sattrs)
|
|
|
|
|
|
|
|
return map(lambda result: user.User(result), results)
|
|
|
|
|
2007-08-23 08:44:00 -05:00
|
|
|
def add_user(self,user,user_container=None):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Add a user. user is a ipa.user.User object"""
|
2007-08-06 09:05:53 -05:00
|
|
|
|
2007-08-20 14:10:50 -05:00
|
|
|
user_dict = user.toDict()
|
|
|
|
|
2007-08-17 16:27:54 -05:00
|
|
|
# convert to a regular dict before sending
|
2007-08-23 08:44:00 -05:00
|
|
|
result = self.transport.add_user(user_dict, user_container)
|
2007-08-06 09:05:53 -05:00
|
|
|
return result
|
|
|
|
|
|
|
|
def get_all_users(self):
|
2007-08-17 09:03:33 -05:00
|
|
|
"""Get as a list of User objects all users in the directory"""
|
2007-08-06 09:05:53 -05:00
|
|
|
result = self.transport.get_all_users()
|
|
|
|
|
|
|
|
all_users = []
|
0000-12-31 18:09:24 -05:50
|
|
|
for attrs in result:
|
2007-08-17 09:03:33 -05:00
|
|
|
if attrs is not None:
|
|
|
|
all_users.append(user.User(attrs))
|
2007-08-06 09:05:53 -05:00
|
|
|
|
|
|
|
return all_users
|
|
|
|
|
2007-11-16 11:59:32 -06:00
|
|
|
def get_custom_fields(self):
|
|
|
|
"""Get custom user fields"""
|
|
|
|
result = self.transport.get_custom_fields()
|
|
|
|
return result
|
|
|
|
|
|
|
|
def set_custom_fields(self, schema):
|
|
|
|
"""Set custom user fields"""
|
|
|
|
result = self.transport.set_custom_fields(schema)
|
2007-08-06 09:05:53 -05:00
|
|
|
return result
|
2007-08-13 15:41:38 -05:00
|
|
|
|
2008-04-25 12:33:01 -05:00
|
|
|
def find_users(self, criteria, sattrs=None, sizelimit=-1, timelimit=-1):
|
2007-08-28 18:01:07 -05:00
|
|
|
"""Return a list: counter followed by a User object for each user that
|
|
|
|
matches the criteria. If the results are truncated, counter will
|
|
|
|
be set to -1"""
|
2008-04-25 12:33:01 -05:00
|
|
|
result = self.transport.find_users(criteria, sattrs, sizelimit, timelimit)
|
2007-08-28 18:01:07 -05:00
|
|
|
counter = result[0]
|
2007-08-13 15:41:38 -05:00
|
|
|
|
2007-08-28 18:01:07 -05:00
|
|
|
users = [counter]
|
|
|
|
for attrs in result[1:]:
|
2007-08-17 09:03:33 -05:00
|
|
|
if attrs is not None:
|
|
|
|
users.append(user.User(attrs))
|
2007-08-13 15:41:38 -05:00
|
|
|
|
|
|
|
return users
|
|
|
|
|
2007-08-20 12:50:11 -05:00
|
|
|
def update_user(self,user):
|
|
|
|
"""Update a user entry."""
|
2007-08-14 16:22:05 -05:00
|
|
|
|
2007-08-20 12:50:11 -05:00
|
|
|
result = self.transport.update_user(user.origDataDict(), user.toDict())
|
2007-08-14 16:22:05 -05:00
|
|
|
return result
|
2007-08-17 09:03:33 -05:00
|
|
|
|
2007-08-28 12:52:08 -05:00
|
|
|
def delete_user(self,uid):
|
|
|
|
"""Delete a user entry."""
|
|
|
|
|
|
|
|
result = self.transport.delete_user(uid)
|
|
|
|
return result
|
|
|
|
|
2007-10-01 16:33:16 -05:00
|
|
|
def modifyPassword(self,principal,oldpass,newpass):
|
2007-09-11 01:48:53 -05:00
|
|
|
"""Modify a user's password"""
|
|
|
|
|
2007-10-01 16:33:16 -05:00
|
|
|
result = self.transport.modifyPassword(principal,oldpass,newpass)
|
2007-09-11 01:48:53 -05:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
2007-11-20 21:45:29 -06:00
|
|
|
def mark_user_active(self,uid):
|
|
|
|
"""Set a user as active by uid."""
|
|
|
|
|
|
|
|
result = self.transport.mark_user_active(uid)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def mark_user_inactive(self,uid):
|
2007-08-17 09:03:33 -05:00
|
|
|
"""Set a user as inactive by uid."""
|
|
|
|
|
2007-11-20 21:45:29 -06:00
|
|
|
result = self.transport.mark_user_inactive(uid)
|
2007-08-17 09:03:33 -05:00
|
|
|
return result
|
2007-08-24 14:42:56 -05:00
|
|
|
|
|
|
|
# Groups support
|
|
|
|
|
2007-09-25 15:35:43 -05:00
|
|
|
def get_groups_by_member(self,member_dn,sattrs=None):
|
|
|
|
"""Gets the groups that member_dn belongs to.
|
|
|
|
If sattrs is not None then only those
|
|
|
|
attributes will be returned, otherwise all available
|
|
|
|
attributes are returned. The result is a list of groups."""
|
|
|
|
results = self.transport.get_groups_by_member(member_dn,sattrs)
|
|
|
|
|
|
|
|
return map(lambda result: group.Group(result), results)
|
|
|
|
|
2007-08-24 14:42:56 -05:00
|
|
|
def add_group(self,group,group_container=None):
|
|
|
|
"""Add a group. group is a ipa.group.Group object"""
|
|
|
|
|
|
|
|
group_dict = group.toDict()
|
|
|
|
|
|
|
|
# dn is set on the server-side
|
|
|
|
del group_dict['dn']
|
|
|
|
|
|
|
|
# convert to a regular dict before sending
|
|
|
|
result = self.transport.add_group(group_dict, group_container)
|
|
|
|
return result
|
|
|
|
|
2008-04-25 12:33:01 -05:00
|
|
|
def find_groups(self, criteria, sattrs=None, sizelimit=-1, timelimit=-1):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Find groups whose cn matches the criteria. Wildcards are
|
|
|
|
acceptable. Returns a list of Group objects."""
|
2008-04-25 12:33:01 -05:00
|
|
|
result = self.transport.find_groups(criteria, sattrs, sizelimit, timelimit)
|
2007-09-19 10:42:34 -05:00
|
|
|
counter = result[0]
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-09-19 10:42:34 -05:00
|
|
|
groups = [counter]
|
|
|
|
for attrs in result[1:]:
|
2007-08-24 14:42:56 -05:00
|
|
|
if attrs is not None:
|
|
|
|
groups.append(group.Group(attrs))
|
|
|
|
|
|
|
|
return groups
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def add_member_to_group(self, member_dn, group_dn):
|
2007-09-26 17:47:34 -05:00
|
|
|
"""Add a member to an existing group.
|
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.add_member_to_group(member_dn, group_dn)
|
2007-09-26 17:47:34 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def add_members_to_group(self, member_dns, group_dn):
|
2007-09-26 17:47:34 -05:00
|
|
|
"""Add several members to an existing group.
|
|
|
|
member_dns is a list of dns to add
|
|
|
|
|
|
|
|
Returns a list of the dns that were not added.
|
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.add_members_to_group(member_dns, group_dn)
|
2007-09-26 17:47:34 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def remove_member_from_group(self, member_dn, group_dn):
|
2007-09-26 17:47:34 -05:00
|
|
|
"""Remove a member from an existing group.
|
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.remove_member_from_group(member_dn, group_dn)
|
2007-09-26 17:47:34 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def remove_members_from_group(self, member_dns, group_dn):
|
2007-09-26 17:47:34 -05:00
|
|
|
"""Remove several members from an existing group.
|
|
|
|
member_dns is a list of dns to remove
|
|
|
|
|
|
|
|
Returns a list of the dns that were not removed.
|
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.remove_members_from_group(member_dns, group_dn)
|
2007-09-26 17:47:34 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def add_user_to_group(self, user_uid, group_dn):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Add a user to an existing group.
|
2007-10-01 16:33:16 -05:00
|
|
|
user is a uid of the user to add
|
|
|
|
group is the cn of the group to be added to
|
2007-08-24 14:42:56 -05:00
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.add_user_to_group(user_uid, group_dn)
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def add_users_to_group(self, user_uids, group_dn):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Add several users to an existing group.
|
2007-09-26 17:47:34 -05:00
|
|
|
user_uids is a list of uids of the users to add
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-09-26 17:47:34 -05:00
|
|
|
Returns a list of the user uids that were not added.
|
2007-08-24 14:42:56 -05:00
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.add_users_to_group(user_uids, group_dn)
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def remove_user_from_group(self, user_uid, group_dn):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Remove a user from an existing group.
|
2007-10-01 16:33:16 -05:00
|
|
|
user is a uid of the user to remove
|
|
|
|
group is the cn of the group to be removed from
|
2007-08-24 14:42:56 -05:00
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.remove_user_from_group(user_uid, group_dn)
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
def remove_users_from_group(self, user_uids, group_dn):
|
2007-08-24 14:42:56 -05:00
|
|
|
"""Remove several users from an existing group.
|
2007-09-26 17:47:34 -05:00
|
|
|
user_uids is a list of uids of the users to remove
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-09-26 17:47:34 -05:00
|
|
|
Returns a list of the user uids that were not removed.
|
2007-08-24 14:42:56 -05:00
|
|
|
"""
|
|
|
|
|
2007-10-03 20:21:41 -05:00
|
|
|
return self.transport.remove_users_from_group(user_uids, group_dn)
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-09-28 18:01:42 -05:00
|
|
|
def add_groups_to_user(self, group_dns, user_dn):
|
|
|
|
"""Given a list of group dn's add them to the user.
|
|
|
|
|
|
|
|
Returns a list of the group dns that were not added.
|
|
|
|
"""
|
|
|
|
return self.transport.add_groups_to_user(group_dns, user_dn)
|
|
|
|
|
|
|
|
def remove_groups_from_user(self, group_dns, user_dn):
|
|
|
|
"""Given a list of group dn's remove them from the user.
|
|
|
|
|
|
|
|
Returns a list of the group dns that were not removed.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.transport.remove_groups_from_user(group_dns, user_dn)
|
|
|
|
|
2007-08-24 14:42:56 -05:00
|
|
|
def update_group(self,group):
|
|
|
|
"""Update a group entry."""
|
|
|
|
|
2007-08-28 12:52:08 -05:00
|
|
|
return self.transport.update_group(group.origDataDict(), group.toDict())
|
2007-08-24 14:42:56 -05:00
|
|
|
|
2007-10-23 18:46:50 -05:00
|
|
|
def delete_group(self,group_dn):
|
2007-08-28 12:52:08 -05:00
|
|
|
"""Delete a group entry."""
|
|
|
|
|
2007-10-23 18:46:50 -05:00
|
|
|
return self.transport.delete_group(group_dn)
|
2007-08-28 12:52:08 -05:00
|
|
|
|
|
|
|
def add_group_to_group(self, group_cn, tgroup_cn):
|
|
|
|
"""Add a group to an existing group.
|
|
|
|
group_cn is a cn of the group to add
|
|
|
|
tgroup_cn is the cn of the group to be added to
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.transport.add_group_to_group(group_cn, tgroup_cn)
|
2007-10-22 16:06:52 -05:00
|
|
|
|
|
|
|
def attrs_to_labels(self,attrs):
|
|
|
|
"""Convert a list of LDAP attributes into a more readable form."""
|
|
|
|
|
|
|
|
return self.transport.attrs_to_labels(attrs)
|
2007-10-30 14:07:02 -05:00
|
|
|
|
2008-01-04 15:39:41 -06:00
|
|
|
def get_all_attrs(self):
|
|
|
|
"""We have a list of hardcoded attributes -> readable labels. Return
|
|
|
|
that complete list if someone wants it.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.transport.get_all_attrs()
|
|
|
|
|
2008-03-27 08:54:41 -05:00
|
|
|
def group_members(self, groupdn, attr_list, membertype):
|
2007-10-30 14:07:02 -05:00
|
|
|
"""Do a memberOf search of groupdn and return the attributes in
|
|
|
|
attr_list (an empty list returns everything)."""
|
|
|
|
|
2008-03-27 08:54:41 -05:00
|
|
|
results = self.transport.group_members(groupdn, attr_list, membertype)
|
2007-10-30 14:07:02 -05:00
|
|
|
|
2007-10-31 09:08:16 -05:00
|
|
|
counter = results[0]
|
2007-10-30 14:07:02 -05:00
|
|
|
|
2007-10-31 09:08:16 -05:00
|
|
|
entries = [counter]
|
|
|
|
for e in results[1:]:
|
|
|
|
if e is not None:
|
|
|
|
entries.append(user.User(e))
|
|
|
|
|
|
|
|
return entries
|
2007-11-20 21:45:29 -06:00
|
|
|
|
2007-11-20 23:29:03 -06:00
|
|
|
def mark_group_active(self,cn):
|
|
|
|
"""Set a group as active by cn."""
|
|
|
|
|
|
|
|
result = self.transport.mark_group_active(cn)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def mark_group_inactive(self,cn):
|
|
|
|
"""Set a group as inactive by cn."""
|
|
|
|
|
|
|
|
result = self.transport.mark_group_inactive(cn)
|
|
|
|
return result
|
2007-11-20 21:45:29 -06:00
|
|
|
|
|
|
|
# Configuration
|
2007-11-16 11:59:32 -06:00
|
|
|
|
|
|
|
def get_ipa_config(self):
|
|
|
|
"""Get the IPA configuration"""
|
|
|
|
result = self.transport.get_ipa_config()
|
|
|
|
return entity.Entity(result)
|
|
|
|
|
|
|
|
def update_ipa_config(self, config):
|
|
|
|
"""Updates the IPA configuration.
|
|
|
|
|
|
|
|
config is an Entity object.
|
|
|
|
"""
|
|
|
|
result = self.transport.update_ipa_config(config.origDataDict(), config.toDict())
|
|
|
|
return result
|
|
|
|
|
|
|
|
def get_password_policy(self):
|
|
|
|
"""Get the IPA password policy"""
|
|
|
|
result = self.transport.get_password_policy()
|
|
|
|
return entity.Entity(result)
|
|
|
|
|
|
|
|
def update_password_policy(self, policy):
|
|
|
|
"""Updates the IPA password policy.
|
|
|
|
|
|
|
|
policy is an Entity object.
|
|
|
|
"""
|
|
|
|
result = self.transport.update_password_policy(policy.origDataDict(), policy.toDict())
|
|
|
|
return result
|
0000-12-31 18:09:24 -05:50
|
|
|
|
2008-02-26 12:51:56 -06:00
|
|
|
def add_service_principal(self, princ_name, force):
|
|
|
|
return self.transport.add_service_principal(princ_name, force)
|
0000-12-31 18:09:24 -05:50
|
|
|
|
2008-01-11 10:44:23 -06:00
|
|
|
def delete_service_principal(self, principal_dn):
|
|
|
|
return self.transport.delete_service_principal(principal_dn)
|
|
|
|
|
2008-04-25 12:33:01 -05:00
|
|
|
def find_service_principal(self, criteria, sattrs=None, sizelimit=-1, timelimit=-1):
|
2007-12-05 14:17:11 -06:00
|
|
|
"""Return a list: counter followed by a Entity object for each host that
|
|
|
|
matches the criteria. If the results are truncated, counter will
|
|
|
|
be set to -1"""
|
2008-04-25 12:33:01 -05:00
|
|
|
result = self.transport.find_service_principal(criteria, sattrs, sizelimit, timelimit)
|
2007-12-05 14:17:11 -06:00
|
|
|
counter = result[0]
|
|
|
|
|
|
|
|
hosts = [counter]
|
|
|
|
for attrs in result[1:]:
|
|
|
|
if attrs is not None:
|
|
|
|
hosts.append(entity.Entity(attrs))
|
|
|
|
|
|
|
|
return hosts
|
|
|
|
|
0000-12-31 18:09:24 -05:50
|
|
|
def get_keytab(self, princ_name):
|
|
|
|
return self.transport.get_keytab(princ_name)
|
2007-11-13 19:05:02 -06:00
|
|
|
|
2007-11-13 23:04:19 -06:00
|
|
|
# radius support
|
Add radius profile implementations:
get_radius_profile_by_uid
add_radius_profile
update_radius_profile
delete_radius_profile
find_radius_profiles
Rewrite command line arg handling, now support pair entry, interactive
mode with auto completion, reading pairs from a file, better handling
of mandatory values, better help, long arg names now match attribute
name in pairs
Establish mappings for all attributes and names used in clients and
profiles
Add notion of containers to radius clients and profiles in LDAP
Move common code, variables, constants, and strings into the files
radius_client.py, radius_util.py, ipautil.py to eliminate redundant
elements which could get out of sync if modified and to provide access
to other code which might benefit from using these items in the
future.
Add utility functions:
format_list()
parse_key_value_pairs()
Add utility class:
AttributeValueCompleter
Unify attribute usage in radius ldap schema
2007-11-21 12:11:10 -06:00
|
|
|
def get_radius_client_by_ip_addr(self, ip_addr, container=None, sattrs=None):
|
|
|
|
result = self.transport.get_radius_client_by_ip_addr(ip_addr, container, sattrs)
|
2007-11-26 10:12:58 -06:00
|
|
|
return radius_util.RadiusClient(result)
|
2007-11-13 23:04:19 -06:00
|
|
|
|
2007-11-26 18:30:33 -06:00
|
|
|
def add_radius_client(self, client, container=None):
|
2007-11-13 19:05:02 -06:00
|
|
|
client_dict = client.toDict()
|
|
|
|
|
|
|
|
# dn is set on the server-side
|
|
|
|
del client_dict['dn']
|
|
|
|
|
|
|
|
# convert to a regular dict before sending
|
Add radius profile implementations:
get_radius_profile_by_uid
add_radius_profile
update_radius_profile
delete_radius_profile
find_radius_profiles
Rewrite command line arg handling, now support pair entry, interactive
mode with auto completion, reading pairs from a file, better handling
of mandatory values, better help, long arg names now match attribute
name in pairs
Establish mappings for all attributes and names used in clients and
profiles
Add notion of containers to radius clients and profiles in LDAP
Move common code, variables, constants, and strings into the files
radius_client.py, radius_util.py, ipautil.py to eliminate redundant
elements which could get out of sync if modified and to provide access
to other code which might benefit from using these items in the
future.
Add utility functions:
format_list()
parse_key_value_pairs()
Add utility class:
AttributeValueCompleter
Unify attribute usage in radius ldap schema
2007-11-21 12:11:10 -06:00
|
|
|
result = self.transport.add_radius_client(client_dict, container)
|
2007-11-13 19:05:02 -06:00
|
|
|
return result
|
|
|
|
|
2007-11-26 18:30:33 -06:00
|
|
|
def update_radius_client(self, client):
|
2007-11-13 23:04:19 -06:00
|
|
|
result = self.transport.update_radius_client(client.origDataDict(), client.toDict())
|
|
|
|
return result
|
|
|
|
|
Add radius profile implementations:
get_radius_profile_by_uid
add_radius_profile
update_radius_profile
delete_radius_profile
find_radius_profiles
Rewrite command line arg handling, now support pair entry, interactive
mode with auto completion, reading pairs from a file, better handling
of mandatory values, better help, long arg names now match attribute
name in pairs
Establish mappings for all attributes and names used in clients and
profiles
Add notion of containers to radius clients and profiles in LDAP
Move common code, variables, constants, and strings into the files
radius_client.py, radius_util.py, ipautil.py to eliminate redundant
elements which could get out of sync if modified and to provide access
to other code which might benefit from using these items in the
future.
Add utility functions:
format_list()
parse_key_value_pairs()
Add utility class:
AttributeValueCompleter
Unify attribute usage in radius ldap schema
2007-11-21 12:11:10 -06:00
|
|
|
def delete_radius_client(self, ip_addr, container=None):
|
|
|
|
return self.transport.delete_radius_client(ip_addr, container)
|
2007-11-13 23:04:19 -06:00
|
|
|
|
2008-04-25 12:33:01 -05:00
|
|
|
def find_radius_clients(self, criteria, container=None, sattrs=None, sizelimit=-1, timelimit=-1):
|
|
|
|
result = self.transport.find_radius_clients(criteria, container, sattrs, sizelimit, timelimit)
|
2007-11-14 14:32:08 -06:00
|
|
|
counter = result[0]
|
|
|
|
|
|
|
|
users = [counter]
|
|
|
|
for attrs in result[1:]:
|
|
|
|
if attrs is not None:
|
|
|
|
users.append(user.User(attrs))
|
|
|
|
|
|
|
|
return users
|
|
|
|
|
2007-11-26 18:30:33 -06:00
|
|
|
def get_radius_profile_by_uid(self, uid, user_profile=None, sattrs=None):
|
|
|
|
result = self.transport.get_radius_profile_by_uid(uid, user_profile, sattrs)
|
|
|
|
return radius_util.RadiusClient(result)
|
|
|
|
|
|
|
|
def add_radius_profile(self, profile, user_profile=None):
|
|
|
|
profile_dict = profile.toDict()
|
|
|
|
|
|
|
|
# dn is set on the server-side
|
|
|
|
del profile_dict['dn']
|
|
|
|
|
|
|
|
# convert to a regular dict before sending
|
|
|
|
result = self.transport.add_radius_profile(profile_dict, user_profile)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def update_radius_profile(self, profile):
|
|
|
|
result = self.transport.update_radius_profile(profile.origDataDict(), profile.toDict())
|
|
|
|
return result
|
|
|
|
|
|
|
|
def delete_radius_profile(self, ip_addr, user_profile=None):
|
|
|
|
return self.transport.delete_radius_profile(ip_addr, user_profile)
|
|
|
|
|
2008-04-25 12:33:01 -05:00
|
|
|
def find_radius_profiles(self, criteria, user_profile=None, sattrs=None, sizelimit=-1, timelimit=-1):
|
|
|
|
result = self.transport.find_radius_profiles(criteria, user_profile, sattrs, sizelimit, timelimit)
|
2007-11-26 18:30:33 -06:00
|
|
|
counter = result[0]
|
|
|
|
|
|
|
|
users = [counter]
|
|
|
|
for attrs in result[1:]:
|
|
|
|
if attrs is not None:
|
|
|
|
users.append(user.User(attrs))
|
|
|
|
|
|
|
|
return users
|
|
|
|
|