sysdb.h revision 17195241500e46272018d7897d6e87249870caf2
7fb4c0766e858653c9776474005a6ae6d94828afgryzor System Database Header
7fb4c0766e858653c9776474005a6ae6d94828afgryzor Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
7fb4c0766e858653c9776474005a6ae6d94828afgryzor This program is free software; you can redistribute it and/or modify
7fb4c0766e858653c9776474005a6ae6d94828afgryzor it under the terms of the GNU General Public License as published by
7fb4c0766e858653c9776474005a6ae6d94828afgryzor the Free Software Foundation; either version 3 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen This program is distributed in the hope that it will be useful,
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen but WITHOUT ANY WARRANTY; without even the implied warranty of
7fb4c0766e858653c9776474005a6ae6d94828afgryzor MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7fb4c0766e858653c9776474005a6ae6d94828afgryzor GNU General Public License for more details.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd You should have received a copy of the GNU General Public License
7fb4c0766e858653c9776474005a6ae6d94828afgryzor along with this program. If not, see <http://www.gnu.org/licenses/>.
e7eb98e34575dcf6536530bcf08e00d7ab3d3124gryzor#define SYSDB_TMPL_USER_BASE SYSDB_USERS_CONTAINER","SYSDB_DOM_BASE
e7eb98e34575dcf6536530bcf08e00d7ab3d3124gryzor#define SYSDB_TMPL_GROUP_BASE SYSDB_GROUPS_CONTAINER","SYSDB_DOM_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_CUSTOM_BASE SYSDB_CUSTOM_CONTAINER","SYSDB_DOM_BASE
b03f9485e6dfcf9326e6122f91eaa1ced8939818jim#define SYSDB_TMPL_NETGROUP_BASE SYSDB_NETGROUP_CONTAINER","SYSDB_DOM_BASE
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh#define SYSDB_TMPL_RANGE_BASE SYSDB_RANGE_CONTAINER","SYSDB_BASE
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_DOMAIN_ID_RANGE_CLASS "domainIDRange"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_TRUSTED_AD_DOMAIN_RANGE_CLASS "TrustedADDomainRange"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_ORIG_NETGROUP_EXTERNAL_HOST "originalExternalHost"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_PRIMARY_GROUP_GIDNUM "origPrimaryGroupGidNumber"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_CANONICAL_UPN "canonicalUserPrincipalName"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_ORIG_MEMBER_USER "originalMemberUser"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_ORIG_MEMBER_HOST "originalMemberHost"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_PWSID_FILTER "(&("SYSDB_UC")("SYSDB_SID_STR"=%s))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_GRSID_FILTER "(&("SYSDB_GC")("SYSDB_SID_STR"=%s))"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_SID_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_SID_STR"=%s))"
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_USER SYSDB_NAME"=%s,"SYSDB_TMPL_USER_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_GROUP SYSDB_NAME"=%s,"SYSDB_TMPL_GROUP_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_NETGROUP SYSDB_NAME"=%s,"SYSDB_TMPL_NETGROUP_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_CUSTOM_SUBTREE "cn=%s,"SYSDB_TMPL_CUSTOM_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_CUSTOM SYSDB_NAME"=%s,cn=%s,"SYSDB_TMPL_CUSTOM_BASE
7fb4c0766e858653c9776474005a6ae6d94828afgryzor#define SYSDB_TMPL_RANGE SYSDB_NAME"=%s,"SYSDB_TMPL_RANGE_BASE
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh/* sysdb version check macros */
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh ERROR("Removing cache files in "DB_PATH" should fix the issue, " \
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh "but note that removing cache files will also remove all of your " \
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh "cached credentials.\n")
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh ERROR("Lower version of database is expected!\n"); \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor ERROR("Higher version of database is expected!\n"); \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor ERROR("In order to upgrade the database, you must run SSSD.\n"); \
7fb4c0766e858653c9776474005a6ae6d94828afgryzor/* use this in daemons */
7fb4c0766e858653c9776474005a6ae6d94828afgryzor/* use this in tools */
7fb4c0766e858653c9776474005a6ae6d94828afgryzor/* sysdb_attrs helper functions */
7fb4c0766e858653c9776474005a6ae6d94828afgryzorstruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
7fb4c0766e858653c9776474005a6ae6d94828afgryzor/* values are copied in the structure, allocated on "attrs" */
7fb4c0766e858653c9776474005a6ae6d94828afgryzorint sysdb_attrs_add_mem(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_add_lc_name_alias(struct sysdb_attrs *attrs,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char *value);
7fb4c0766e858653c9776474005a6ae6d94828afgryzor const char *name);
7fb4c0766e858653c9776474005a6ae6d94828afgryzorint sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
7fb4c0766e858653c9776474005a6ae6d94828afgryzorint sysdb_attrs_get_el_ext(struct sysdb_attrs *attrs, const char *name,
7fb4c0766e858653c9776474005a6ae6d94828afgryzorint sysdb_attrs_steal_string(struct sysdb_attrs *attrs,
7fb4c0766e858653c9776474005a6ae6d94828afgryzorint sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char **string);
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooherrno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_get_int32_t(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char *newname);
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedoohint sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char *domain,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char *const *list);
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooherrno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char **_primary);
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooherrno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char *primary,
888cb40bdeec5abf452bd85d6bf63b26d5913d4chumbedooh const char ***_aliases);
7fb4c0766e858653c9776474005a6ae6d94828afgryzorerrno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
b03f9485e6dfcf9326e6122f91eaa1ced8939818jim const char *ldap_attr,
b03f9485e6dfcf9326e6122f91eaa1ced8939818jim const char *name,
b03f9485e6dfcf9326e6122f91eaa1ced8939818jim const char **_cname);
b03f9485e6dfcf9326e6122f91eaa1ced8939818jimerrno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
7fb4c0766e858653c9776474005a6ae6d94828afgryzor/* convert an ldb error into an errno error */
727872d18412fc021f03969b8641810d8896820bhumbedooh/* DNs related helper functions */
0d0ba3a410038e179b695446bb149cce6264e0abnderrno_t sysdb_get_rdn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedoohstruct ldb_dn *sysdb_user_dn(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
0d0ba3a410038e179b695446bb149cce6264e0abnd const char *name);
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedoohstruct ldb_dn *sysdb_group_dn(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
727872d18412fc021f03969b8641810d8896820bhumbedooh const char *name);
0d0ba3a410038e179b695446bb149cce6264e0abndstruct ldb_dn *sysdb_netgroup_base_dn(TALLOC_CTX *mem_ctx,
0d0ba3a410038e179b695446bb149cce6264e0abnderrno_t sysdb_group_dn_name(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
0d0ba3a410038e179b695446bb149cce6264e0abndstruct ldb_dn *sysdb_base_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx);
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen const char *subtree_name);
0d0ba3a410038e179b695446bb149cce6264e0abndstruct ldb_dn *sysdb_custom_subtree_dn(TALLOC_CTX *mem_ctx,
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd const char *subtree_name);
const char* forest);
bool allow_upgrade);
const char *db_path,
const char *name,
const char *name,
struct sysdb_netgroup_ctx {
char *hostname;
char *username;
char *domainname;
} triple;
char *groupname;
} value;
const char *netgroup,
const char *name,
const char *name,
const char **attributes,
const char *netgrname,
const char **attributes,
bool ignore_not_found);
bool ignore_not_found);
int scope,
const char *filter,
const char **attrs,
const char *name,
const char **attrs,
const char **attrs,
const char *sid_str,
const char **attrs,
const char *name,
const char **attrs,
const char **attrs,
const char *sid_str,
const char **attrs,
const char *name,
const char **attrs,
int mod_op);
const char *name,
int mod_op);
const char *name,
int mod_op);
const char *name,
int mod_op);
const char *name,
const char *gecos,
const char *homedir,
const char *shell);
const char *name,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
int cache_timeout,
int cache_timeout,
const char *name,
const char *original_dn,
const char *sid_str,
bool posix,
const char *name,
const char *description,
char **missing,
int cache_timeout,
int mod_op);
const char *name,
const char *pwd,
const char *gecos,
const char *homedir,
const char *shell,
const char *orig_dn,
char **remove_attrs,
const char *name,
enum sysdb_member_type {
const char *group,
const char *member,
bool is_dn);
const char *group,
const char *member,
bool is_dn);
const char *member,
const char *const *add_groups,
const char *const *del_groups);
const char *member,
const char *const *add_groups,
const char *const *del_groups);
const char *username,
const char *password);
const char *name,
const char *password,
bool just_check,
const char *object_name,
const char *subtree_name,
const char *filter,
const char *subtree_name,
const char **attrs,
const char *object_name,
const char *subtree_name,
const char **attrs,
const char *object_name,
const char *subtree_name);
const char *expression,
const char *asq_attribute,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *sub_filter,
const char **attrs,
const char *name);
const char *sid_str);
int attr_count,
const char *attr_name,
char ***_list);
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,
char **remove_attrs);
const char *name,
char ***_direct_parents);
#define SYSDB_IDMAP_ATTRS { \
SYSDB_NAME, \
NULL }
const char *dom_name,
const char *dom_sid,
const char *sid_str,
const char **attrs,