sysdb.h revision 08d9d10747da6900971cdd8fced05ca66f5111e2
/*
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_USER_CLASS "user"
#define SYSDB_GROUP_CLASS "group"
#define SYSDB_NAME "name"
#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_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_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_USN "entryUSN"
#define SYSDB_HIGH_USN "highestUSN"
#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
"objectClass"
NULL}
NULL}
NULL}
NULL}
#define SYSDB_INITGR_ATTR SYSDB_MEMBEROF
#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, \
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_list;
struct sysdb_ctx;
struct sysdb_handle;
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);
const char *newname);
const char *attr_name,
const char *domain,
const char **list);
const char *attr_name,
const char *domain,
int num_values);
/* 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 *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 tevent_context *ev,
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 tevent_context *ev,
struct sss_domain_info *domain,
const char *db_path,
struct sss_domain_info *domain,
/* FIXME: REMOVE */
typedef void (*sysdb_callback_t)(void *, int, struct ldb_result *);
/* functions to retrieve information from sysdb
* These functions automatically starts an operation
* therefore they cannot be called within a transaction */
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
const char *expression,
struct sss_domain_info *domain,
const char *name,
struct ldb_result **res);
struct sss_domain_info *domain,
struct ldb_result **res);
struct sss_domain_info *domain,
struct sss_domain_info *domain,
const char *name,
struct sss_domain_info *domain,
const char *name,
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) */
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char **attrs,
struct ldb_message **msg);
/* Search Group (gy gid or name) */
struct sss_domain_info *domain,
const char *name,
const char **attrs,
struct ldb_message **msg);
struct sss_domain_info *domain,
const char **attrs,
struct ldb_message **msg);
/* Replace entry attrs */
struct sysdb_attrs *attrs,
int mod_op);
/* Replace user attrs */
struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Replace group attrs */
struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
int mod_op);
/* Allocate a new id */
struct sss_domain_info *domain,
/* Add user (only basic attrs and w/o checks) */
struct sss_domain_info *domain,
const char *name,
const char *gecos,
const char *homedir,
const char *shell);
/* Add user (all checks) */
struct sss_domain_info *domain,
const char *name,
const char *gecos,
const char *homedir,
const char *shell,
struct sysdb_attrs *attrs,
int cache_timeout);
/* Add group (only basic attrs and w/o checks) */
struct sss_domain_info *domain,
/* Add group (all checks) */
struct sss_domain_info *domain,
struct sysdb_attrs *attrs,
int cache_timeout);
/* mod_op must be either LDB_FLAG_MOD_ADD or LDB_FLAG_MOD_DELETE */
int mod_op);
struct sss_domain_info *domain,
struct sss_domain_info *domain,
const char *name,
const char *pwd,
const char *gecos,
const char *homedir,
const char *shell,
struct sysdb_attrs *attrs,
struct sss_domain_info *domain,
const char *name,
struct sysdb_attrs *attrs,
struct sss_domain_info *domain,
const char *group,
const char *user);
struct sss_domain_info *domain,
const char *group,
const char *user);
/* 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 */
struct sss_domain_info *domain,
const char *username,
const char *password);
struct confdb_ctx *cdb,
struct ldb_message *ldb_msg,
struct sss_domain_info *domain,
const char *name,
struct confdb_ctx *cdb,
struct sss_domain_info *domain,
const char *object_name,
const char *subtree_name,
struct sysdb_attrs *attrs);
struct sss_domain_info *domain,
const char *filter,
const char *subtree_name,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *object_name,
const char *subtree_name,
const char **attrs,
struct ldb_message ***_msgs);
struct sss_domain_info *domain,
const char *object_name,
const char *subtree_name);
struct sss_domain_info *domain,
const char *expression,
const char *asq_attribute,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
struct sss_domain_info *domain,
const char *sub_filter,
const char **attrs,
struct ldb_message ***msgs);
struct sss_domain_info *domain,
#endif /* __SYS_DB_H__ */