sysdb.h revision 8d9e0547a864cee05ab36bc988300c0cfa986025
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder System Database Header
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder This program is free software; you can redistribute it and/or modify
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder it under the terms of the GNU General Public License as published by
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder the Free Software Foundation; either version 3 of the License, or
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder (at your option) any later version.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder This program is distributed in the hope that it will be useful,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder GNU General Public License for more details.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder You should have received a copy of the GNU General Public License
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_CONTAINER "cn=Netgroups"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TMPL_USER_BASE SYSDB_USERS_CONTAINER",cn=%s,"SYSDB_BASE
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TMPL_GROUP_BASE SYSDB_GROUPS_CONTAINER",cn=%s,"SYSDB_BASE
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_TMPL_CUSTOM_BASE SYSDB_CUSTOM_CONTAINER",cn=%s,"SYSDB_BASE
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#define SYSDB_TMPL_NETGROUP_BASE SYSDB_NETGROUP_CONTAINER",cn=%s,"SYSDB_BASE
d81905a5b924415c524d702df26204683c82c12eChristian Maeder#define SYSDB_TMPL_RANGE_BASE SYSDB_RANGE_CONTAINER",cn=%s,"SYSDB_BASE
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SELINUX_USERMAP_CLASS "selinuxusermap"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_DOMAIN_ID_RANGE_CLASS "domainIDRange"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TRUSTED_AD_DOMAIN_RANGE_CLASS "TrustedADDomainRange"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_LAST_ONLINE_AUTH "lastOnlineAuth"
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke#define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_AUTHORIZED_HOST "authorizedHost"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_TRIPLE "netgroupTriple"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_NETGROUP_EXTERNAL_HOST "originalExternalHost"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SERVERHOSTNAME "serverHostname"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SELINUX_HOST_PRIORITY "hostPriority"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PRIMARY_GROUP "ADPrimaryGroupID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_MEMBEROF "originalMemberOf"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_MEMBER_USER "originalMemberUser"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_MEMBER_HOST "originalMemberHost"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SECONDARY_BASE_RID "secondaryBaseRID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NEXTID_FILTER "("SYSDB_NEXTID"=*)"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_UC "objectclass="SYSDB_USER_CLASS
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_GC "objectclass="SYSDB_GROUP_CLASS
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NC "objectclass="SYSDB_NETGROUP_CLASS
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_MPGC "|("SYSDB_UC")("SYSDB_GC")"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
d81905a5b924415c524d702df26204683c82c12eChristian Maeder#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_GRENT_MPG_FILTER "("SYSDB_MPGC")"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME"=%s)("SYSDB_NAME_ALIAS"=%s)("SYSDB_MEMBEROF"=%s))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_HAS_ENUMERATED "has_enumerated"
5b5f3190cc8d51a7942dda33a1ec45345cca5028Thiemo Wiedemeyer#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TMPL_USER SYSDB_NAME"=%s,"SYSDB_TMPL_USER_BASE
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TMPL_GROUP SYSDB_NAME"=%s,"SYSDB_TMPL_GROUP_BASE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_TMPL_NETGROUP SYSDB_NAME"=%s,"SYSDB_TMPL_NETGROUP_BASE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_TMPL_CUSTOM_SUBTREE "cn=%s,"SYSDB_TMPL_CUSTOM_BASE
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maeder#define SYSDB_TMPL_CUSTOM SYSDB_NAME"=%s,cn=%s,"SYSDB_TMPL_CUSTOM_BASE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_TMPL_RANGE SYSDB_NAME"=%s,"SYSDB_TMPL_RANGE_BASE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* sysdb version check macros */
2353f65833a3da763392f771223250cd50b8d873Christian Maeder ERROR("Removing cache files in "DB_PATH" should fix the issue, " \
d81905a5b924415c524d702df26204683c82c12eChristian Maeder "but note that removing cache files will also remove all of your " \
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder "cached credentials.\n")
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_VERSION_LOWER_ERROR(ret) do { \
2353f65833a3da763392f771223250cd50b8d873Christian Maeder ERROR("Lower version of database is expected!\n"); \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_VERSION_HIGHER_ERROR(ret) do { \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ERROR("Higher version of database is expected!\n"); \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder ERROR("In order to upgrade the database, you must run SSSD.\n"); \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* use this in daemons */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* use this in tools */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* sysdb_attrs helper functions */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* values are copied in the structure, allocated on "attrs" */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_attrs_add_val(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *name, const struct ldb_val *val);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_string(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_long(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_uint32(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_attrs_copy_values(struct sysdb_attrs *src,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name);
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maederint sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maederint sysdb_attrs_get_el_ext(struct sysdb_attrs *attrs, const char *name,
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder bool alloc, struct ldb_message_element **el);
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maederint sysdb_attrs_steal_string(struct sysdb_attrs *attrs,
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Lueckeint sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder const char **string);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maederint sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder TALLOC_CTX *mem_ctx, const char ***string);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maederint sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maederint sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char *const *list);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maedererrno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char **_primary);
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maedererrno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char ***_aliases);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_get_real_name(TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char **_cname);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder/* convert an ldb error into an errno error */
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder/* DNs related helper functions */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_get_rdn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *_dn, char **_name, char **_val);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_user_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_group_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_netgroup_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_netgroup_base_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_group_dn_name(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_domain_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_base_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_custom_subtree_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederchar *sysdb_group_strdn(TALLOC_CTX *mem_ctx,
5cfeedad8c9d43f62f8e8b85ab73c0dd4e91d976Christian Maederstruct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct sss_domain_info *sysdb_ctx_get_domain(struct sysdb_ctx *sysdb);
2353f65833a3da763392f771223250cd50b8d873Christian Maederint compare_ldb_dn_comp_num(const void *m1, const void *m2);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* functions to start and finish transactions */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_transaction_start(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_transaction_commit(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_transaction_cancel(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* functions related to subdomains */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domuser_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domuser_by_uid(TALLOC_CTX *mem_ctx,
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_store_domuser(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_delete_domuser(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domgroup_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domgroup_by_gid(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_store_domgroup(struct sss_domain_info *domain,
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_delete_domgroup(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_subdom_getpwnam(TALLOC_CTX *mem_ctx,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maederint sysdb_subdom_getgrnam(TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luetticherrno_t sysdb_range_create(struct sysdb_ctx *sysdb, struct range_info *range);
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maedererrno_t sysdb_update_ranges(struct sysdb_ctx *sysdb,
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder/* Sysdb initialization.
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder * call this function *only* once to initialize the database and get
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * the sysdb ctx */
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* used to initialize only one domain database.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Do NOT use if sysdb_init has already been called */
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_init_domain_and_sysdb(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_to_domain(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* functions to retrieve information from sysdb
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * These functions automatically starts an operation
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * therefore they cannot be called within a transaction */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder enum {SYSDB_NETGROUP_TRIPLE_VAL, SYSDB_NETGROUP_GROUP_VAL} type;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maederint sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maederint sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
1e3950d5c1f0e041dd7677856e43f07796567d5bChristian Maeder/* functions that modify the databse
2353f65833a3da763392f771223250cd50b8d873Christian Maeder * they have to be called within a transaction
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder * See sysdb_transaction_send()/_recv() */
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder/* Delete Entry */
3a9d784341454573b50b32fa1b494e7418df3086Christian Maederint sysdb_delete_entry(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_recursive(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Search Entry */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Search User (by uid or name) */
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maederint sysdb_search_user_by_uid(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Search Group (by gid or name) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_group_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_group_by_gid(TALLOC_CTX *mem_ctx,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Search Netgroup (by name) */
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maederint sysdb_search_netgroup_by_name(TALLOC_CTX *mem_ctx,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Replace entry attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Replace user attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_user_attr(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Replace group attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_group_attr(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Replace netgroup attrs */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederint sysdb_set_netgroup_attr(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Allocate a new id */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_get_new_id(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder/* Add user (only basic attrs and w/o checks) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_add_basic_user(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Add user (all checks) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Add group (only basic attrs and w/o checks) */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederint sysdb_add_basic_group(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Add group (all checks) */
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_add_group(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Add netgroup (only basic attrs and w/o checks) */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederint sysdb_add_basic_netgroup(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *name, const char *description);
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_add_netgroup(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* mod_op must be either LDB_FLAG_MOD_ADD or LDB_FLAG_MOD_DELETE */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_mod_group_member(struct sysdb_ctx *sysdb,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maederint sysdb_store_user(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_store_group(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maederint sysdb_add_group_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_remove_group_member(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_update_members(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *const *add_groups,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *const *del_groups);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_netgroup_tuple(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_remove_netgroup_tuple(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_mod_netgroup_tuple(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_remove_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_mod_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Password caching function.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * If you are in a transaction ignore sysdb and pass in the handle.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * If you are not in a transaction pass NULL in handle and provide sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * in this case a transaction will be automatically started and the
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * function will be completely wrapped in it's own sysdb transaction */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_cache_password(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t check_failed_login_attempts(struct confdb_ctx *cdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_cache_auth(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maederint sysdb_store_custom(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_custom(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_custom(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_user(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_groups(TALLOC_CTX *mem_ctx,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maederint sysdb_delete_group(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_netgroups(TALLOC_CTX *mem_ctx,
const char *name);
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 *object_sid);
const char *dom_name,
const char *dom_sid,