yast2-ldap

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
LdapAgent Class Reference

An interface class between YaST2 and Ldap Agent. More...

`#include <LdapAgent.h>`

Inheritance diagram for LdapAgent:

## Public Member Functions
| LdapAgent ()
virtual | ~LdapAgent ()
virtual YCPValue | Read (const YCPPath &path, const YCPValue &arg=YCPNull(), const YCPValue &opt=YCPNull())
virtual YCPBoolean | Write (const YCPPath &path, const YCPValue &arg, const YCPValue &arg2=YCPNull())
virtual YCPValue | Execute (const YCPPath &path, const YCPValue &arg=YCPNull(), const YCPValue &arg2=YCPNull())
virtual YCPList | Dir (const YCPPath &path)
virtual YCPValue | otherCommand (const YCPTerm &term)

## Private Member Functions
string | getValue (const YCPMap map, const string key)
int | getIntValue (const YCPMap map, const string key, int deflt)
bool | getBoolValue (const YCPMap map, const string key)
YCPList | getListValue (const YCPMap map, const string key)
StringList | ycplist2stringlist (YCPList l)
YCPList | stringlist2ycplist (StringList sl)
YCPList | stringlist2ycplist_low (StringList sl)
YCPMap | getGroupEntry (LDAPEntry *entry, string member_attribute)
YCPMap | getUserEntry (LDAPEntry *entry)
YCPMap | getSearchedEntry (LDAPEntry *entry, bool sinlge_value)
YCPMap | getObjectAttributes (string dn)
YCPBoolean | deleteSubTree (string dn)
YCPBoolean | moveWithSubtree (string dn, string new_dn, string parent_dn)
YCPBoolean | copyOneEntry (string dn, string new_dn)
void | debug_exception (LDAPException e, string action)
void | debug_referral (LDAPReferralException e, string action)
void | set_tls_options (YCPMap args, string tls)
void | generate_attr_list (LDAPAttributeList *attrs, YCPMap map)
void | generate_mod_list (LDAPModList *modlist, YCPMap map, YCPValue attrs)

## Private Attributes
int | port
string | hostname
string | bind_dn
string | bind_pw
string | ldap_error
string | server_error
bool | tls_error
int | ldap_error_code
bool | ldap_initialized
string | userpw_hash
LDAPConnection * | ldap
LDAPConstraints * | cons
LDAPSchema * | schema
YCPMap | users
YCPMap | users_by_name
YCPMap | users_by_uidnumber
YCPMap | usernames
YCPMap | userdns
YCPMap | uids
YCPMap | homes
YCPMap | user_items
YCPMap | groups
YCPMap | groups_by_name
YCPMap | groups_by_gidnumber
YCPMap | groupnames
YCPMap | gids
YCPMap | group_items

## Detailed Description

An interface class between YaST2 and Ldap Agent.

## Constructor & Destructor Documentation

LdapAgent::LdapAgent | ( | ) |  |

Default constructor.

Constructor

References cons, ldap, ldap_initialized, schema, and tls_error.

LdapAgent::~LdapAgent | ( | ) |  |
| virtual

Destructor.

Destructor

References cons, ldap, and schema.

## Member Function Documentation

YCPBoolean LdapAgent::copyOneEntry | ( | string | dn,
|  | string | new_dn
| ) |  |
| private

copy the LDAP entry to new place (+ changes DN-constructing attribute, like cn,uid,ou etc.)

Parameters

  dn | DN of original entry
  new_dn | new DN (= new place)

References YCPList::add(), YCPMap::add(), YCPList::contains(), debug_exception(), generate_attr_list(), getSearchedEntry(), ldap, ldap_error, YCPMap::value(), and y2debug.

Referenced by moveWithSubtree().

void LdapAgent::debug_exception | ( | LDAPException | e,
|  | string | action
| ) |  |
| private

log the output of an exception and set the return value from agent's call

References ldap_error, ldap_error_code, server_error, and y2error.

Referenced by copyOneEntry(), deleteSubTree(), Execute(), getObjectAttributes(), moveWithSubtree(), Read(), and Write().

void LdapAgent::debug_referral | ( | LDAPReferralException | e,
|  | string | action
| ) |  |
| private

log the output of Referral Exception

References y2milestone.

Referenced by Execute(), and Read().

YCPBoolean LdapAgent::deleteSubTree | ( | string | dn) |  |
| private

deletes all children of given entry

delete children of LDAP entry (code from rhafer)

References debug_exception(), ldap, and y2debug.

Referenced by Write().

YCPList LdapAgent::Dir | ( | const YCPPath & | path) |  |
| virtual

Provides SCR Dir ().

Dir

Implements SCRAgent.

References y2error.

YCPValue LdapAgent::Execute | ( | const YCPPath & | path,
|  | const YCPValue & | arg = `YCPNull()`,
|  | const YCPValue & | arg2 = `YCPNull()`
| ) |  |
| virtual

Provides SCR Execute ().

Execute

initialization: Execute (.ldap,$[ "hostname": <host>, "port": <port>, "use_tls": "no"|"yes"|"try" ] )

ping: Execute (.ldap.ping, $[ "hostname": <host>, "port": <port> ] ) returns true if server is running

ppolicy: Execute (.ldap.ppolicy, $["hostname": <host>, "port": <port>, "bind_dn": <dn>] ) returns true if server suports Password Policy (feature 301179):

rhafer: 'To detect if the server does support LDAP Password Policies you can send it a LDAP Bind Request with the Password Policy Control attached and marked as "critical". The bind-dn should ether be set to the base-dn of the LDAP Database or a child of it (the entry itself does not need to exist in the Database). The bind-pw most not be empty (just some random string is fine) If the server supports Password Policies you'll get back Error Code 49: "Invalid credentials". if it does not support Password Policies you'll get Error Code 53: "Server is unwilling to perform" with the additional message: "critical control unavailable in context"'

bind: Execute(.ldap.bind, $[ "bind_dn": binddn, "bindpw": bindpw] ) for anonymous acess, call bind with empty map

unbind: Execute(.ldap.unbind)

close the connection, delete object

Initialize schema: read and parse it

LDAP users search command Read(.ldap.users.search, <search_map>) -> result list (more special work is done than in generic search)

References YCPMap::add(), addBlanks(), ANSWER, YCPMap::begin(), bind_dn, bind_pw, cons, debug_exception(), debug_referral(), DEFAULT_PORT, YCPMap::end(), getBoolValue(), getGroupEntry(), getIntValue(), getListValue(), getUserEntry(), getValue(), gids, group_items, groupnames, groups, groups_by_gidnumber, groups_by_name, homes, hostname, YCPMapIterator::key(), ldap, ldap_error, ldap_error_code, ldap_initialized, PC, port, schema, server_error, set_tls_options(), YCPList::size(), tls_error, uids, user_items, userdns, usernames, users, users_by_name, users_by_uidnumber, YCPMap::value(), YCPList::value(), y2debug, y2error, y2warning, and ycplist2stringlist().

void LdapAgent::generate_attr_list | ( | LDAPAttributeList * | attrs,
|  | YCPMap | map
| ) |  |
| private

creates attributes for new LDAP object and fills their values

References YCPMap::begin(), YCPMap::end(), and ycplist2stringlist().

Referenced by copyOneEntry(), and Write().

void LdapAgent::generate_mod_list | ( | LDAPModList * | modlist,
|  | YCPMap | map,
|  | YCPValue | attrs
| ) |  |
| private

creates list of modifications for LDAP object for removing attribute, use give it empty value

creates list of modifications for LDAP object for removing attribute, give it empty value

References YCPMap::begin(), YCPMap::end(), y2warning, and ycplist2stringlist().

Referenced by Write().

bool LdapAgent::getBoolValue | ( | const YCPMap | map,
|  | const string | key
| ) |  |
| private

References getIntValue(), and YCPMap::value().

Referenced by Execute(), Read(), and Write().

YCPMap LdapAgent::getGroupEntry | ( | LDAPEntry * | entry,
|  | string | member_attribute
| ) |  |
| private

Return YCP of group, given as LDAP object

Parameters

  entry | LDAP object of the group [item of search result]
  member_attribute | name of attribute with members ("member"/"uniquemember")

Return YCP of group, given as LDAP object

Parameters

  entry | LDAP object of the group [item of search result]
  member_attribute | name of attribute with members ("member"/"uniqueMember")

References YCPMap::add(), stringlist2ycplist(), and tolower().

Referenced by Execute().

int LdapAgent::getIntValue | ( | const YCPMap | map,
|  | const string | key,
|  | int | deflt
| ) |  |
| private

Search the map for value of given key

Parameters

  map | YCP Map to look in
  key | key we are looking for
  deflt | the default value to be returned if key is not found

References YCPMap::value().

Referenced by Execute(), getBoolValue(), and Read().

YCPList LdapAgent::getListValue | ( | const YCPMap | map,
|  | const string | key
| ) |  |
| private

References YCPMap::value().

Referenced by Execute(), and Read().

YCPMap LdapAgent::getObjectAttributes | ( | string | dn) |  |
| private

searches for one object and gets all his non-empty attributes

Parameters

  dn | object's dn

Returns
  map of type $[ attr_name: [] ]

References YCPMap::add(), debug_exception(), getSearchedEntry(), and ldap.

Referenced by Write().

YCPMap LdapAgent::getSearchedEntry | ( | LDAPEntry * | entry,
|  | bool | single_values
| ) |  |
| private

creates YCPMap describing object returned as a part of LDAP search call

Parameters

  single_values | if true, return string when argument has only one value (otherwise return always list)

creates YCPMap describing object returned as a part of LDAP search command

Parameters

  single_values | if true, return string when argument has only one value

References YCPList::add(), YCPMap::add(), stringlist2ycplist(), and YCPList::value().

Referenced by copyOneEntry(), getObjectAttributes(), and Read().

YCPMap LdapAgent::getUserEntry | ( | LDAPEntry * | entry) |  |
| private

Return YCP of user, given as LDAP object

Parameters

  entry | LDAP object of the user [item of search result]

References YCPList::add(), YCPMap::add(), stringlist2ycplist(), tolower(), and YCPMap::value().

Referenced by Execute().

string LdapAgent::getValue | ( | const YCPMap | map,
|  | const string | key
| ) |  |
| private

search the map for value of given key; both key and value have to be strings when key is not present, empty string is returned

References YCPMap::value().

Referenced by Execute(), Read(), set_tls_options(), and Write().

YCPBoolean LdapAgent::moveWithSubtree | ( | string | dn,
|  | string | new_dn,
|  | string | parent_dn
| ) |  |
| private

move the entry in LDAP tree with all its children

Parameters

  dn | DN of original entry
  new_dn | new DN (= new place)
  parent_dn | DN of the new parent of the entry

References copyOneEntry(), debug_exception(), ldap, ldap_error, and y2debug.

Referenced by Write().

YCPValue LdapAgent::otherCommand | ( | const YCPTerm & | term) |  |
| virtual

Used for mounting the agent.

otherCommand

Reimplemented from SCRAgent.

References YCPTerm::name().

YCPValue LdapAgent::Read | ( | const YCPPath & | path,
|  | const YCPValue & | arg = `YCPNull()`,
|  | const YCPValue & | opt = `YCPNull()`
| ) |  |
| virtual

Provides SCR Read ().

Parameters

  path | Path that should be read.
  arg | Additional parameter.

Read

error: Read(.ldap.error) -> returns last error message

generic LDAP search command Read(.ldap.search, <search_map>) -> result list/map of objects (return value depends on value of "return_map" parameter

get the users map (previously searched by users.search) Read(.ldap.users) -> map

get the groups map (previously searched by users.search) Read(.ldap.groups) -> map

get the map of object class with given name Read(.ldap.schema.oc, $[ "name": name]) -> map

get the map of attribute type with given name Read(.ldap.schema.at, $[ "name": name]) -> map

get the mapping of usernames to uid's (used for users module) DEPRECATED, users_by_name is empty now Read(.ldap.users.by_name) -> map

get the mapping of uid numbers to user names (used for users module) Read(.ldap.users.by_uidnumber) -> map

get the list of home directories (used for users module) Read(.ldap.users.homes) -> list of homes

get the list of UID's (used for users module) Read(.ldap.users.uids) -> list

get the list of user names (used for users module) Read(.ldap.users.usernames) -> list

get the list of user DN's (used for users module) Read(.ldap.users.userdns) -> list

get the items for user table (used for users module) Read(.ldap.users.itemlist) -> list of items

get the map of gid's indexed by group names (used for users module) DEPRECATED, groups_by_name is empty now Read(.ldap.groups.by_name) -> map

get the mapping of gid numbers to group names (used for users module) Read(.ldap.groups.by_uidnumber) -> map

get the list of GID's (used for users module) Read(.ldap.groups.gids) -> list

get the list of group names (used for users module) Read(.ldap.groups.groupnames) -> list

get the items for group table (used for users module) Read(.ldap.groups.itemlist) -> list of items

check if given object class exists in schema Read(.ldap.schema.oc.check, $[ "name": name]) -> boolean

Implements SCRAgent.

References YCPMap::add(), YCPList::add(), cons, debug_exception(), debug_referral(), getBoolValue(), getIntValue(), getListValue(), getSearchedEntry(), getValue(), gids, group_items, groupnames, groups, groups_by_gidnumber, groups_by_name, homes, ldap, ldap_error, ldap_error_code, ldap_initialized, PC, schema, server_error, stringlist2ycplist(), tls_error, uids, user_items, userdns, usernames, users, users_by_name, users_by_uidnumber, y2debug, y2error, and ycplist2stringlist().

void LdapAgent::set_tls_options | ( | YCPMap | args,
|  | string | set_tls
| ) |  |
| private

Adapt TLS Settings of existing LDAP connection

Adapt TLS Settings of existing LDAP connection args is argument map got from YCP call tls is string, values are "yes" and "try"

References getValue().

Referenced by Execute().

YCPList LdapAgent::stringlist2ycplist | ( | StringList | sl) |  |
| private

converts StringList object to YCPList value

References YCPList::add().

Referenced by getGroupEntry(), getSearchedEntry(), getUserEntry(), and Read().

YCPList LdapAgent::stringlist2ycplist_low | ( | StringList | sl) |  |
| private

converts StringList object to YCPList value + each item is lowercased

References YCPList::add(), and tolower().

YCPBoolean LdapAgent::Write | ( | const YCPPath & | path,
|  | const YCPValue & | arg,
|  | const YCPValue & | arg2 = `YCPNull()`
| ) |  |
| virtual

Provides SCR Write ().

Write

generic LDAP add command Write(.ldap.add, $[ "dn": dn ], <add_map>) -> boolean

generic LDAP modify command Write(.ldap.modify, <arg_map>, <modify_map>) -> boolean

- modify_map is list of attributes and its values to add or modify.
- To remove some attribute, use empty value ("" or []) for it.
- arg_map has to contain "dn" entry.
- If arg_map contains "rdn" key, object will be renamed using the value of "rdn" as new Relative Distinguished Name. For moving, use "newParentDN" value for new parent DN of object.
- "new_dn" new DN of renamed object
- If arg_map contains "check_attrs" key (with true value), there will be done search for current object's attributes before modify. When some attribute in modify_map has empty value it will be ignored, if object currently has not this attribute. Otherwise ("check_attrs" is false as default), this situation leads to error message, because non-existent attribute is set for deletion.

generic LDAP delete command Write(.ldap.delete, $[ "dn" : dn ]) -> boolean

Implements SCRAgent.

References debug_exception(), deleteSubTree(), generate_attr_list(), generate_mod_list(), getBoolValue(), getObjectAttributes(), getValue(), ldap, ldap_error, ldap_initialized, moveWithSubtree(), PC, y2debug, and y2error.

StringList LdapAgent::ycplist2stringlist | ( | YCPList | l) |  |
| private

converts YCPList to StringList object

References YCPList::size(), and YCPList::value().

Referenced by Execute(), generate_attr_list(), generate_mod_list(), and Read().

## Member Data Documentation

string LdapAgent::bind_dn
| private

Referenced by Execute().

string LdapAgent::bind_pw
| private

Referenced by Execute().

LDAPConstraints* LdapAgent::cons
| private

Referenced by Execute(), LdapAgent(), Read(), and ~LdapAgent().

YCPMap LdapAgent::gids
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::group_items
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::groupnames
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::groups
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::groups_by_gidnumber
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::groups_by_name
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::homes
| private

Referenced by Execute(), and Read().

string LdapAgent::hostname
| private

Referenced by Execute().

LDAPConnection* LdapAgent::ldap
| private

Referenced by copyOneEntry(), deleteSubTree(), Execute(), getObjectAttributes(), LdapAgent(), moveWithSubtree(), Read(), Write(), and ~LdapAgent().

string LdapAgent::ldap_error
| private

Referenced by copyOneEntry(), debug_exception(), Execute(), moveWithSubtree(), Read(), and Write().

int LdapAgent::ldap_error_code
| private

Referenced by debug_exception(), Execute(), and Read().

bool LdapAgent::ldap_initialized
| private

Referenced by Execute(), LdapAgent(), Read(), and Write().

int LdapAgent::port
| private

Agent private variables

Referenced by Execute().

LDAPSchema* LdapAgent::schema
| private

Referenced by Execute(), LdapAgent(), Read(), and ~LdapAgent().

string LdapAgent::server_error
| private

Referenced by debug_exception(), Execute(), and Read().

bool LdapAgent::tls_error
| private

Referenced by Execute(), LdapAgent(), and Read().

YCPMap LdapAgent::uids
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::user_items
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::userdns
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::usernames
| private

Referenced by Execute(), and Read().

string LdapAgent::userpw_hash
| private

YCPMap LdapAgent::users
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::users_by_name
| private

Referenced by Execute(), and Read().

YCPMap LdapAgent::users_by_uidnumber
| private

Referenced by Execute(), and Read().

The documentation for this class was generated from the following files:

- LdapAgent.h
- LdapAgent.cc