sysdb.h revision 9674f0f018c65a9af6b18dd0a4e515f726803d27
/*
SSSD
System Database Header
Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SYS_DB_H__
#define __SYS_DB_H__
#include <tevent.h>
#define SYSDB_CONF_SECTION "config/sysdb"
#define CACHE_SYSDB_FILE "cache_%s.ldb"
#define LOCAL_SYSDB_FILE "sssd.ldb"
#define SYSDB_BASE "cn=sysdb"
#define SYSDB_DOM_BASE "cn=%s,cn=sysdb"
#define SYSDB_USERS_CONTAINER "cn=users"
#define SYSDB_GROUPS_CONTAINER "cn=groups"
#define SYSDB_CUSTOM_CONTAINER "cn=custom"
#define SYSDB_NETGROUP_CONTAINER "cn=Netgroups"
#define SYSDB_USER_CLASS "user"
#define SYSDB_GROUP_CLASS "group"
#define SYSDB_NETGROUP_CLASS "netgroup"
#define SYSDB_HOST_CLASS "host"
#define SYSDB_NAME "name"
#define SYSDB_NAME_ALIAS "nameAlias"
#define SYSDB_OBJECTCLASS "objectClass"
#define SYSDB_NEXTID "nextID"
#define SYSDB_UIDNUM "uidNumber"
#define SYSDB_GIDNUM "gidNumber"
#define SYSDB_CREATE_TIME "createTimestamp"
#define SYSDB_PWD "userPassword"
#define SYSDB_FULLNAME "fullName"
#define SYSDB_HOMEDIR "homeDirectory"
#define SYSDB_SHELL "loginShell"
#define SYSDB_MEMBEROF "memberOf"
#define SYSDB_DISABLED "disabled"
#define SYSDB_MEMBER "member"
#define SYSDB_MEMBERUID "memberUid"
#define SYSDB_POSIX "isPosix"
#define SYSDB_DEFAULTGROUP "defaultGroup"
#define SYSDB_GECOS "gecos"
#define SYSDB_LOCALE "locale"
#define SYSDB_KEYBOARD "keyboard"
#define SYSDB_SESSION "session"
#define SYSDB_LAST_LOGIN "lastLogin"
#define SYSDB_LAST_ONLINE_AUTH "lastOnlineAuth"
#define SYSDB_USERPIC "userPicture"
#define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
#define SYSDB_LAST_UPDATE "lastUpdate"
#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
#define SYSDB_AUTHORIZED_HOST "authorizedHost"
#define SYSDB_NETGROUP_TRIPLE "netgroupTriple"
#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
#define SYSDB_ORIG_NETGROUP_EXTERNAL_HOST "originalExternalHost"
#define SYSDB_NETGROUP_DOMAIN "nisDomain"
#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
#define SYSDB_DESCRIPTION "description"
#define SYSDB_CACHEDPWD "cachedPassword"
#define SYSDB_UUID "uniqueID"
#define SYSDB_UPN "userPrincipalName"
#define SYSDB_CCACHE_FILE "ccacheFile"
#define SYSDB_ORIG_DN "originalDN"
#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
#define SYSDB_ORIG_MEMBEROF "originalMemberOf"
#define SYSDB_ORIG_MEMBER_USER "originalMemberUser"
#define SYSDB_ORIG_MEMBER_HOST "originalMemberHost"
#define SYSDB_USN "entryUSN"
#define SYSDB_HIGH_USN "highestUSN"
#define SYSDB_HAS_ENUMERATED "has_enumerated"
#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
NULL}
NULL}
NULL}
NULL}
NULL}
#define SYSDB_INITGR_ATTR SYSDB_MEMBEROF
NULL}
#define SYSDB_MOD_ADD LDB_FLAG_MOD_ADD
#define SYSDB_MOD_DEL LDB_FLAG_MOD_DELETE
#define SYSDB_MOD_REP LDB_FLAG_MOD_REPLACE
struct confdb_ctx;
struct sysdb_ctx;
struct sysdb_ctx_list {
char *db_path;
};
struct sysdb_attrs {
int num;
struct ldb_message_element *a;
};
/* sysdb_attrs helper functions */
/* values are copied in the structure, allocated on "attrs" */
struct ldb_message_element **el);
const char **string);
bool *value);
const char *newname);
const char *attr_name,
const char *domain,
const char *const *list);
const char *attr_name,
const char *domain,
int num_values);
struct sysdb_attrs *attrs,
const char *ldap_attr,
const char **_primary);
struct sysdb_attrs *attrs,
const char *primary,
bool lowercase,
const char ***_aliases);
struct sysdb_attrs **attr_list,
const char *ldap_attr,
char ***name_list);
const char *name,
const char **_cname);
struct ldb_message **msgs,
struct sysdb_attrs ***attrs);
/* convert an ldb error into an errno error */
int sysdb_error_to_errno(int ldberr);
/* DNs related helper functions */
const char *domain);
const char *domain);
const char *domain, const char *object_name,
const char *subtree_name);
const char *domain,
const char *subtree_name);
/* functions to start and finish transactions */
/* Sysdb initialization.
* call this function *only* once to initialize the database and get
* the sysdb ctx */
struct confdb_ctx *cdb,
const char *alt_db_path,
bool allow_upgrade,
struct sysdb_ctx_list **_ctx_list);
/* used to initialize only one domain database.
* Do NOT use if sysdb_init has already been called */
struct sss_domain_info *domain,
const char *db_path,
const char *path,
struct sysdb_ctx_list **_list);
struct sss_domain_info *domain,
/* functions to retrieve information from sysdb
* These functions automatically starts an operation
* therefore they cannot be called within a transaction */
const char *name,
struct ldb_result **res);
struct ldb_result **res);
struct ldb_result **res);
const char *name,
struct ldb_result **res);
struct ldb_result **res);
struct ldb_result **res);
struct sysdb_netgroup_ctx {
union {
struct {
char *hostname;
char *username;
char *domainname;
} triple;
char *groupname;
} value;
};
const char *netgroup,
struct ldb_result **res);
const char *name,
struct ldb_result **res);
const char *name,
const char **attributes,
struct ldb_result **res);
const char *netgrname,
const char **attributes,
struct ldb_result **res);
/* functions that modify the databse
* they have to be called within a transaction
* See sysdb_transaction_send()/_recv() */
/* Delete Entry */
bool ignore_not_found);
bool ignore_not_found);
/* Search Entry */
int scope,
const char *filter,
const char **attrs,
struct ldb_message ***msgs);
/* Search User (by uid or name) */
const char *name,
const char **attrs,
struct ldb_message **msg);
const char **attrs,
struct ldb_message **msg);
/* Search Group (by gid or name) */
const char *name,
const char **attrs,
struct ldb_message **msg);
const char **attrs,
struct ldb_message **msg);
/* Search Netgroup (by name) */
const char *name,
const char **attrs,
struct ldb_message **msg);
/* Replace entry attrs */
struct sysdb_attrs *attrs,
int mod_op);
/* Replace user attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Replace group attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Replace netgroup attrs */
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Allocate a new id */
/* Add user (only basic attrs and w/o checks) */
const char *name,
const char *gecos,
const char *homedir,
const char *shell);
/* Add user (all checks) */
const char *name,
const char *gecos,
const char *homedir,
const char *shell,
struct sysdb_attrs *attrs,
int cache_timeout,
const char *name,
const char *original_dn,
/* Add group (only basic attrs and w/o checks) */
/* Add group (all checks) */
struct sysdb_attrs *attrs,
int cache_timeout,
const char *name,
const char *original_dn, bool posix,
/* Add netgroup (only basic attrs and w/o checks) */
const char *name, const char *description);
const char *name,
const char *description,
struct sysdb_attrs *attrs,
int cache_timeout,
/* mod_op must be either LDB_FLAG_MOD_ADD or LDB_FLAG_MOD_DELETE */
int mod_op);
const char *name,
const char *pwd,
const char *gecos,
const char *homedir,
const char *shell,
struct sysdb_attrs *attrs,
char **remove_attrs,
const char *name,
struct sysdb_attrs *attrs,
enum sysdb_member_type {
};
const char *group,
const char *member,
enum sysdb_member_type type);
const char *group,
const char *member,
enum sysdb_member_type type);
const char *member,
enum sysdb_member_type type,
const char *const *add_groups,
const char *const *del_groups);
const char *netgroup,
const char *hostname,
const char *username,
const char *domainname);
const char *netgroup,
const char *hostname,
const char *username,
const char *domainname);
const char *netgroup,
const char *hostname,
const char *username,
const char *domainname,
int mod_op);
const char *netgroup,
const char *member_netgroup);
const char *netgroup,
const char *member_netgroup);
const char *netgroup,
const char *member_netgroup,
int mod_op);
/* Password caching function.
* If you are in a transaction ignore sysdb and pass in the handle.
* If you are not in a transaction pass NULL in handle and provide sysdb,
* in this case a transaction will be automatically started and the
* function will be completely wrapped in it's own sysdb transaction */
const char *username,
const char *password);
struct ldb_message *ldb_msg,
const char *name,
struct confdb_ctx *cdb,
bool just_check,
const char *object_name,
const char *subtree_name,
struct sysdb_attrs *attrs);
const char *filter,
const char *subtree_name,
const char **attrs,
struct ldb_message ***msgs);
const char *object_name,
const char *subtree_name,
const char **attrs,
struct ldb_message ***_msgs);
const char *object_name,
const char *subtree_name);
const char *expression,
const char *asq_attribute,
const char **attrs,
struct ldb_message ***msgs);
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
const char *name);
struct sysdb_attrs **attrs,
int attr_count,
const char *attr_name,
char ***_list);
struct ldb_result *res,
struct sysdb_netgroup_ctx ***entries);
char **sanitized);
const char *attr_name,
bool *value);
const char *cn_value,
const char *attr_name,
bool value);
bool *has_enumerated);
bool enumerated);
const char *name,
enum sysdb_member_type type,
char **remove_attrs);
struct sss_domain_info *dom,
enum sysdb_member_type mtype,
const char *name,
char ***_direct_parents);
#endif /* __SYS_DB_H__ */