sysdb.h revision 8d9e0547a864cee05ab36bc988300c0cfa986025
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder/*
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SSSD
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder System Database Header
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
3f69b6948966979163bdfe8331c38833d5d90ecdChristian Maeder
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
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
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*/
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder#ifndef __SYS_DB_H__
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define __SYS_DB_H__
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder#include "util/util.h"
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder#include "confdb/confdb.h"
fbc7d11880751ef87862b1f4650b16c01c6763f1Klaus Luettich#include <tevent.h>
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define CACHE_SYSDB_FILE "cache_%s.ldb"
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder#define LOCAL_SYSDB_FILE "sssd.ldb"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_BASE "cn=sysdb"
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder#define SYSDB_DOM_BASE "cn=%s,cn=sysdb"
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder#define SYSDB_USERS_CONTAINER "cn=users"
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder#define SYSDB_GROUPS_CONTAINER "cn=groups"
38c817b94e0a5b1ae94178b1075c187e07bcc5e1Christian Maeder#define SYSDB_CUSTOM_CONTAINER "cn=custom"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_CONTAINER "cn=Netgroups"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_RANGE_CONTAINER "cn=ranges"
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
d81905a5b924415c524d702df26204683c82c12eChristian Maeder#define SYSDB_SUBDOMAIN_CLASS "subdomain"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_RANGE_CLASS "idrange"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_USER_CLASS "user"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_GROUP_CLASS "group"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_CLASS "netgroup"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_HOST_CLASS "host"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_HOSTGROUP_CLASS "hostgroup"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SELINUX_USERMAP_CLASS "selinuxusermap"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SELINUX_CLASS "selinux"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ID_RANGE_CLASS "idRange"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_DOMAIN_ID_RANGE_CLASS "domainIDRange"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_TRUSTED_AD_DOMAIN_RANGE_CLASS "TrustedADDomainRange"
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_NAME "name"
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder#define SYSDB_NAME_ALIAS "nameAlias"
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanu#define SYSDB_OBJECTCLASS "objectClass"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NEXTID "nextID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_UIDNUM "uidNumber"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_GIDNUM "gidNumber"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_CREATE_TIME "createTimestamp"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PWD "userPassword"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_FULLNAME "fullName"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_HOMEDIR "homeDirectory"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SHELL "loginShell"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_MEMBEROF "memberOf"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_DISABLED "disabled"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder#define SYSDB_MEMBER "member"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_MEMBERUID "memberUid"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_GHOST "ghost"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_POSIX "isPosix"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_USER_CATEGORY "userCategory"
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder#define SYSDB_HOST_CATEGORY "hostCategory"
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder#define SYSDB_GECOS "gecos"
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder#define SYSDB_LAST_LOGIN "lastLogin"
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
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich#define SYSDB_LAST_UPDATE "lastUpdate"
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_AUTHORIZED_HOST "authorizedHost"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
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_DOMAIN "nisDomain"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_DESCRIPTION "description"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_FQDN "fqdn"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SERVERHOSTNAME "serverHostname"
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SELINUX_SEEALSO "seeAlso"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SELINUX_USER "selinuxUser"
d81905a5b924415c524d702df26204683c82c12eChristian Maeder#define SYSDB_SELINUX_ENABLED "enabled"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SELINUX_HOST_PRIORITY "hostPriority"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder#define SYSDB_CACHEDPWD "cachedPassword"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_UUID "uniqueID"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SID "objectSID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PRIMARY_GROUP "ADPrimaryGroupID"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_SID_STR "objectSIDString"
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#define SYSDB_UPN "userPrincipalName"
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maeder#define SYSDB_CCACHE_FILE "ccacheFile"
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ORIG_DN "originalDN"
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
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_USN "entryUSN"
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#define SYSDB_HIGH_USN "highestUSN"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
d81905a5b924415c524d702df26204683c82c12eChristian Maeder#define SYSDB_SSH_PUBKEY "sshPublicKey"
d81905a5b924415c524d702df26204683c82c12eChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SUBDOMAIN_REALM "realmName"
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_SUBDOMAIN_FLAT "flatName"
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder#define SYSDB_SUBDOMAIN_ID "domainID"
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#define SYSDB_BASE_ID "baseID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_ID_RANGE_SIZE "idRangeSize"
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_BASE_RID "baseRID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_SECONDARY_BASE_RID "secondaryBaseRID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_DOMAIN_ID "domainID"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NEXTID_FILTER "("SYSDB_NEXTID"=*)"
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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
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))"
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder#define SYSDB_PWENT_FILTER "("SYSDB_UC")"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder
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))"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_GRENT_FILTER "("SYSDB_GC")"
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")"
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder
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
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder#define SYSDB_HAS_ENUMERATED "has_enumerated"
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder
5b5f3190cc8d51a7942dda33a1ec45345cca5028Thiemo Wiedemeyer#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder SYSDB_CACHE_EXPIRE, \
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder SYSDB_INITGR_EXPIRE, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_OBJECTCLASS
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_GIDNUM, SYSDB_GECOS, \
2353f65833a3da763392f771223250cd50b8d873Christian Maeder SYSDB_HOMEDIR, SYSDB_SHELL, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_DEFAULT_ATTRS, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder NULL}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder SYSDB_MEMBERUID, \
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder SYSDB_GHOST, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_DEFAULT_ATTRS, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder NULL}
d81905a5b924415c524d702df26204683c82c12eChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
4a2f7efdf67dfcda0946f1b6373f41976ddea7a4Christian Maeder SYSDB_NETGROUP_MEMBER, \
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder SYSDB_DEFAULT_ATTRS, \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder NULL}
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_INITGR_ATTR SYSDB_MEMBEROF
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder SYSDB_DEFAULT_ATTRS, \
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanu SYSDB_ORIG_DN, \
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maeder NULL}
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_MOD_ADD LDB_FLAG_MOD_ADD
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_MOD_DEL LDB_FLAG_MOD_DELETE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_MOD_REP LDB_FLAG_MOD_REPLACE
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* sysdb version check macros */
2353f65833a3da763392f771223250cd50b8d873Christian Maeder#define SYSDB_VERSION_ERROR_HINT \
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")
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder#define SYSDB_VERSION_LOWER_ERROR(ret) do { \
2353f65833a3da763392f771223250cd50b8d873Christian Maeder if (ret == EUCLEAN) { \
2353f65833a3da763392f771223250cd50b8d873Christian Maeder ERROR("Lower version of database is expected!\n"); \
6352f3c31da3043783a13be6594aacb2147378baRazvan Pascanu SYSDB_VERSION_ERROR_HINT; \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder } \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder} while(0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_VERSION_HIGHER_ERROR(ret) do { \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder if (ret == EMEDIUMTYPE) { \
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 SYSDB_VERSION_ERROR_HINT; \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder } \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder} while(0)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* use this in daemons */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_VERSION_ERROR_DAEMON(ret) \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_VERSION_LOWER_ERROR(ret)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* use this in tools */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder#define SYSDB_VERSION_ERROR(ret) \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_VERSION_LOWER_ERROR(ret); \
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder SYSDB_VERSION_HIGHER_ERROR(ret)
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maederstruct confdb_ctx;
980c2505814d75dc689de1412f4de30b4d96314fRazvan Pascanustruct sysdb_ctx;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct sysdb_ctx_list {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx **dbs;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t num_dbs;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char *db_path;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder};
4b1833c7d3af466e6bcba24f16304e0a78e8da87Christian Maeder
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maederstruct sysdb_attrs {
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder int num;
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder struct ldb_message_element *a;
980c2505814d75dc689de1412f4de30b4d96314fRazvan Pascanu};
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* sysdb_attrs helper functions */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maederstruct sysdb_subdom {
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char *realm;
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char *name;
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char *flat_name;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *id;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder};
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct range_info {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char *name;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t base_id;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t id_range_size;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t base_rid;
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t secondary_base_rid;
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder char *trusted_dom_sid;
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder};
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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 Luettich const char *name, const char *str);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder const char *name, bool value);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_long(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *name, long value);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_uint32(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *name, uint32_t value);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettichint sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name, time_t value);
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_attrs_copy_values(struct sysdb_attrs *src,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *dst,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name);
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maederint sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder struct ldb_message_element **el);
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,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *name, char *str);
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 Maeder bool *value);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_attrs_get_uint16_t(struct sysdb_attrs *attrs, const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint16_t *value);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maederint sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t *value);
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
fdac680252d7347858bd67b4c2a2aaa52e623815Christian Maeder const char *newname);
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maeder
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maederint sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich const char *attr_name,
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke const char *domain,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char *const *list);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maedererrno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder struct sysdb_attrs *attrs,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char *ldap_attr,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char **_primary);
a9e804dbec424ec36e34bab955cbe90edac5baa6Christian Maedererrno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder struct sysdb_attrs *attrs,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char *primary,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder bool lowercase,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder const char ***_aliases);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder struct sysdb_attrs **attr_list,
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luettich size_t attr_count,
b76d27eba526ecac2a20400fa505ec5c642ae7d2Dominik Luecke const char *ldap_attr,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder char ***name_list);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_get_real_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char **_cname);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder struct ldb_message **msgs,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct sysdb_attrs ***attrs);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder/* convert an ldb error into an errno error */
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maederint sysdb_error_to_errno(int ldberr);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
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 Maeder const char *dn_str, char **name);
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 Maeder const char *object_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct ldb_dn *sysdb_custom_subtree_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederchar *sysdb_user_strdn(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *domain, const char *name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederchar *sysdb_group_strdn(TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder const char *domain, const char *name);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
5cfeedad8c9d43f62f8e8b85ab73c0dd4e91d976Christian Maederstruct ldb_context *sysdb_ctx_get_ldb(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederstruct sss_domain_info *sysdb_ctx_get_domain(struct sysdb_ctx *sysdb);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maederint compare_ldb_dn_comp_num(const void *m1, const void *m2);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* functions related to subdomains */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_get_subdomains(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *subdomain_count,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_subdom ***subdomain_list);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_domain_create(struct sysdb_ctx *sysdb, const char *domain_name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_update_subdomains(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int num_subdoms,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_subdom *subdoms);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_get_subdomain_context(TALLOC_CTX *mem_ctx,
0b73fd9cab131c1b25b542007c98b5f8717b1d36Klaus Luettich struct sysdb_ctx *sysdb,
0b73fd9cab131c1b25b542007c98b5f8717b1d36Klaus Luettich struct sss_domain_info *subdomain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx **subdomain_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_master_domain_get_info(TALLOC_CTX *mem_ctx,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder struct sysdb_ctx *sysdb,
0b73fd9cab131c1b25b542007c98b5f8717b1d36Klaus Luettich struct sysdb_subdom **info);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_master_domain_add_info(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_subdom *domain_info);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
0b73fd9cab131c1b25b542007c98b5f8717b1d36Klaus Luettich
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domuser_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domuser_by_uid(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uid_t uid,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_store_domuser(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *pwd,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder uid_t uid, gid_t gid,
4f1815aad02f2d2a7a34864bbafd563961b72886Christian Maeder const char *gecos,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *homedir,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *shell,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *attrs,
5b5f3190cc8d51a7942dda33a1ec45345cca5028Thiemo Wiedemeyer char **remove_attrs,
5b5f3190cc8d51a7942dda33a1ec45345cca5028Thiemo Wiedemeyer uint64_t cache_timeout,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder time_t now);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_delete_domuser(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name, uid_t uid);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domgroup_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_search_domgroup_by_gid(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder gid_t gid,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_store_domgroup(struct sss_domain_info *domain,
d81905a5b924415c524d702df26204683c82c12eChristian Maeder const char *name,
d81905a5b924415c524d702df26204683c82c12eChristian Maeder gid_t gid,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder struct sysdb_attrs *attrs,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder uint64_t cache_timeout,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder time_t now);
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_delete_domgroup(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name, gid_t gid);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_subdom_getpwnam(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
4a2f7efdf67dfcda0946f1b6373f41976ddea7a4Christian Maeder struct ldb_result **res);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maederint sysdb_subdom_getgrnam(TALLOC_CTX *mem_ctx,
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder struct sysdb_ctx *sysdb,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder const char *name,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct ldb_result **res);
3490b73f69b58ab742417b0867d0e2d4a7778cc0Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maedererrno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder size_t *range_count,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder struct range_info ***range_list);
8a5c05062ef501bf725a86a370a5145a198e81fdKlaus Luetticherrno_t sysdb_range_create(struct sysdb_ctx *sysdb, struct range_info *range);
ab2f38d9cd1249f6bc9cc5b838dc2fcd76189c0fChristian Maedererrno_t sysdb_update_ranges(struct sysdb_ctx *sysdb,
974b0baababf2878820de073b8fad8db68bef08aDominik Luecke struct range_info **ranges);
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder/* Sysdb initialization.
083bc1972a66d73749760eab3a90bf4eb9ca7951Christian Maeder * call this function *only* once to initialize the database and get
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder * the sysdb ctx */
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maederint sysdb_init(TALLOC_CTX *mem_ctx,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder struct confdb_ctx *cdb,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder const char *alt_db_path,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder bool allow_upgrade,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx_list **_ctx_list);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* used to initialize only one domain database.
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder * Do NOT use if sysdb_init has already been called */
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_domain_init(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *db_path,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct sysdb_ctx **_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maedererrno_t sysdb_init_domain_and_sysdb(TALLOC_CTX *mem_ctx,
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder struct confdb_ctx *cdb,
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder const char *domain_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *db_path,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sss_domain_info **_domain,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder struct sysdb_ctx **_ctx);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_list_init(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *path,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx_list **_list);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_to_domain(struct sss_domain_info *domain,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *ctx);
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 Maederint sysdb_getpwnam(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
9dd71ac51c9a6e72bcb126224f9c64131698b636Christian Maeder const char *name,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct ldb_result **res);
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maederint sysdb_getpwuid(TALLOC_CTX *mem_ctx,
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder struct sysdb_ctx *sysdb,
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder uid_t uid,
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maeder struct ldb_result **res);
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maederint sysdb_enumpwent(TALLOC_CTX *mem_ctx,
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder struct sysdb_ctx *sysdb,
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder struct ldb_result **res);
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
0ea2cddb8715a770e646895e16b7b8085f49167cChristian Maederint sysdb_getgrnam(TALLOC_CTX *mem_ctx,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct sysdb_ctx *sysdb,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder const char *name,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct ldb_result **res);
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_getgrgid(TALLOC_CTX *mem_ctx,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct sysdb_ctx *sysdb,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder gid_t gid,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct ldb_result **res);
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maeder
beff4152e9f0fe90885458d1a1733b183a2a8816Christian Maederint sysdb_enumgrent(TALLOC_CTX *mem_ctx,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct sysdb_ctx *sysdb,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct ldb_result **res);
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maederstruct sysdb_netgroup_ctx {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder enum {SYSDB_NETGROUP_TRIPLE_VAL, SYSDB_NETGROUP_GROUP_VAL} type;
2353f65833a3da763392f771223250cd50b8d873Christian Maeder union {
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct {
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder char *hostname;
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder char *username;
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder char *domainname;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder } triple;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder char *groupname;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder } value;
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder};
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maedererrno_t sysdb_getnetgr(TALLOC_CTX *mem_ctx,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct sysdb_ctx *sysdb,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder const char *netgroup,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct ldb_result **res);
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maederint sysdb_initgroups(TALLOC_CTX *mem_ctx,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct sysdb_ctx *sysdb,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder const char *name,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct ldb_result **res);
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maederint sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct sysdb_ctx *sysdb,
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder const char *name,
93bc87ee96c68506945dbad8c704badaa42ecf14Christian Maeder const char **attributes,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct ldb_result **res);
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maederint sysdb_get_netgroup_attr(TALLOC_CTX *mem_ctx,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct sysdb_ctx *sysdb,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder const char *netgrname,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder const char **attributes,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct ldb_result **res);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
1e3950d5c1f0e041dd7677856e43f07796567d5bChristian Maeder/* functions that modify the databse
2353f65833a3da763392f771223250cd50b8d873Christian Maeder * they have to be called within a transaction
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder * See sysdb_transaction_send()/_recv() */
3a9d784341454573b50b32fa1b494e7418df3086Christian Maeder
7245138e91992b96b153b8ac527e263d9dc8ff5bChristian Maeder/* Delete Entry */
3a9d784341454573b50b32fa1b494e7418df3086Christian Maederint sysdb_delete_entry(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_dn *dn,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder bool ignore_not_found);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_recursive(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_dn *dn,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder bool ignore_not_found);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Search Entry */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_entry(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_dn *base_dn,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int scope,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *filter,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *msgs_count,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message ***msgs);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Search User (by uid or name) */
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_search_user_by_name(TALLOC_CTX *mem_ctx,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder struct sysdb_ctx *sysdb,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder const char *name,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder const char **attrs,
f39b8dd9651dfcc38b06191cda23cacbfc298323Christian Maeder struct ldb_message **msg);
528539f3d544c24afe14e979fe51f03e50aa6e9cChristian Maeder
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maederint sysdb_search_user_by_uid(TALLOC_CTX *mem_ctx,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder struct sysdb_ctx *sysdb,
0ae7a79e865d4a6022d705d160530682b3c1f825Christian Maeder uid_t uid,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Search Group (by gid or name) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_group_by_name(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_group_by_gid(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder gid_t gid,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Search Netgroup (by name) */
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maederint sysdb_search_netgroup_by_name(TALLOC_CTX *mem_ctx,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder struct sysdb_ctx *sysdb,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message **msg);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maeder/* Replace entry attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_entry_attr(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct ldb_dn *entry_dn,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct sysdb_attrs *attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int mod_op);
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Replace user attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_user_attr(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int mod_op);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Replace group attrs */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_set_group_attr(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int mod_op);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Replace netgroup attrs */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederint sysdb_set_netgroup_attr(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder const char *name,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder struct sysdb_attrs *attrs,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder int mod_op);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Allocate a new id */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_get_new_id(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t *id);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder/* Add user (only basic attrs and w/o checks) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_add_basic_user(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uid_t uid, gid_t gid,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *gecos,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *homedir,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *shell);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Add user (all checks) */
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_add_user(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder uid_t uid, gid_t gid,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *gecos,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *homedir,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *shell,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int cache_timeout,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder time_t now);
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder/* Add group (only basic attrs and w/o checks) */
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maederint sysdb_add_basic_group(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder const char *name, gid_t gid);
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder/* Add group (all checks) */
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_add_group(struct sysdb_ctx *sysdb,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder const char *name, gid_t gid,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder struct sysdb_attrs *attrs,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder int cache_timeout,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder time_t now);
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_add_incomplete_group(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder gid_t gid,
59a10395caff224b2ec541f94dac5082a506c00fChristian Maeder const char *original_dn, bool posix,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder time_t now);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_add_netgroup(struct sysdb_ctx *sysdb,
4b1833c7d3af466e6bcba24f16304e0a78e8da87Christian Maeder const char *name,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder const char *description,
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder struct sysdb_attrs *attrs,
12aef5992d3af07dee81a4e02cf4be65a83f28bcChristian Maeder char **missing,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder int cache_timeout,
4b1833c7d3af466e6bcba24f16304e0a78e8da87Christian Maeder time_t now);
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder
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,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_dn *member_dn,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct ldb_dn *group_dn,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder int mod_op);
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maederint sysdb_store_user(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *name,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder const char *pwd,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder uid_t uid, gid_t gid,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *gecos,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *homedir,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *shell,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct sysdb_attrs *attrs,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder char **remove_attrs,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder uint64_t cache_timeout,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder time_t now);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
2353f65833a3da763392f771223250cd50b8d873Christian Maederint sysdb_store_group(struct sysdb_ctx *sysdb,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder const char *name,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder gid_t gid,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder struct sysdb_attrs *attrs,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder uint64_t cache_timeout,
9d6562465b41f17c7967d4e5678f34811d958cb2Christian Maeder time_t now);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maederenum sysdb_member_type {
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder SYSDB_MEMBER_USER,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder SYSDB_MEMBER_GROUP,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder SYSDB_MEMBER_NETGROUP,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder SYSDB_MEMBER_SERVICE,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder};
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maederint sysdb_add_group_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *group,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *member,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder enum sysdb_member_type type);
2353f65833a3da763392f771223250cd50b8d873Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_remove_group_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *group,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *member,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder enum sysdb_member_type type);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_update_members(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *member,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder enum sysdb_member_type type,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *const *add_groups,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *const *del_groups);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_netgroup_tuple(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *hostname,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *username,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *domainname);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_remove_netgroup_tuple(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *hostname,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *username,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *domainname);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maedererrno_t sysdb_mod_netgroup_tuple(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *hostname,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *username,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *domainname,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int mod_op);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_add_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *member_netgroup);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_remove_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *member_netgroup);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t sysdb_mod_netgroup_member(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *netgroup,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *member_netgroup,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder int mod_op);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
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 Maeder const char *username,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *password);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maedererrno_t check_failed_login_attempts(struct confdb_ctx *cdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message *ldb_msg,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder uint32_t *failed_login_attempts,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder time_t *delayed_until);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_cache_auth(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const uint8_t *authtok,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder size_t authtok_size,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder struct confdb_ctx *cdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder bool just_check,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder time_t *_expire_date,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder time_t *_delayed_until);
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maederint sysdb_store_custom(struct sysdb_ctx *sysdb,
c5a4c5f506ea34fa527065b4187127a18c6e2418Christian Maeder const char *object_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_attrs *attrs);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_custom(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *filter,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *msgs_count,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message ***msgs);
d01f5008234242395b1eac85792fd703acf755d9Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_custom_by_name(TALLOC_CTX *mem_ctx,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *object_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *_count,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message ***_msgs);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_custom(struct sysdb_ctx *sysdb,
2353f65833a3da763392f771223250cd50b8d873Christian Maeder const char *object_name,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *subtree_name);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_asq_search(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_dn *base_dn,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *expression,
a1c6679d00e15a949730ab640159e0adc5b0e3e7Christian Maeder const char *asq_attribute,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder const char **attrs,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder size_t *msgs_count,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct ldb_message ***msgs);
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maederint sysdb_search_users(TALLOC_CTX *mem_ctx,
7968d3a131e5a684ec1ff0c6d88aae638549153dChristian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *sub_filter,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *msgs_count,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder struct ldb_message ***msgs);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_delete_user(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name, uid_t uid);
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_groups(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder const char *sub_filter,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder const char **attrs,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder size_t *msgs_count,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct ldb_message ***msgs);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maederint sysdb_delete_group(struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *name, gid_t gid);
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder
b53688bfed888214b485cf76439d57262d80e0a7Christian Maederint sysdb_search_netgroups(TALLOC_CTX *mem_ctx,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder struct sysdb_ctx *sysdb,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char *sub_filter,
b53688bfed888214b485cf76439d57262d80e0a7Christian Maeder const char **attrs,
size_t *msgs_count,
struct ldb_message ***msgs);
int sysdb_delete_netgroup(struct sysdb_ctx *sysdb,
const char *name);
errno_t sysdb_attrs_to_list(TALLOC_CTX *mem_ctx,
struct sysdb_attrs **attrs,
int attr_count,
const char *attr_name,
char ***_list);
errno_t sysdb_netgr_to_entries(TALLOC_CTX *mem_ctx,
struct ldb_result *res,
struct sysdb_netgroup_ctx ***entries);
errno_t sysdb_dn_sanitize(TALLOC_CTX *mem_ctx, const char *input,
char **sanitized);
errno_t sysdb_get_bool(struct sysdb_ctx *sysdb,
struct ldb_dn *dn,
const char *attr_name,
bool *value);
errno_t sysdb_set_bool(struct sysdb_ctx *sysdb,
struct ldb_dn *dn,
const char *cn_value,
const char *attr_name,
bool value);
errno_t sysdb_has_enumerated(struct sysdb_ctx *sysdb,
bool *has_enumerated);
errno_t sysdb_set_enumerated(struct sysdb_ctx *sysdb,
bool enumerated);
errno_t sysdb_remove_attrs(struct sysdb_ctx *sysdb,
const char *name,
enum sysdb_member_type type,
char **remove_attrs);
errno_t sysdb_get_direct_parents(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
struct sss_domain_info *dom,
enum sysdb_member_type mtype,
const char *name,
char ***_direct_parents);
/* === Functions related to ID-mapping === */
#define SYSDB_IDMAP_CONTAINER "cn=id_mappings"
#define SYSDB_IDMAP_SUBTREE "idmap"
#define SYSDB_IDMAP_MAPPING_OC "id_mapping"
#define SYSDB_IDMAP_FILTER "(objectClass="SYSDB_IDMAP_MAPPING_OC")"
#define SYSDB_IDMAP_SID_ATTR "objectSID"
#define SYSDB_IDMAP_SLICE_ATTR "slice"
#define SYSDB_IDMAP_ATTRS { \
SYSDB_NAME, \
SYSDB_IDMAP_SID_ATTR, \
SYSDB_IDMAP_SLICE_ATTR, \
NULL }
#define SYSDB_TMPL_IDMAP_BASE SYSDB_IDMAP_CONTAINER",cn=%s,"SYSDB_BASE
#define SYSDB_TMPL_IDMAP SYSDB_IDMAP_SID_ATTR"=%s,"SYSDB_TMPL_IDMAP_BASE
struct ldb_dn *sysdb_idmap_dn(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
const char *object_sid);
errno_t sysdb_idmap_store_mapping(struct sysdb_ctx *sysdb,
const char *dom_name,
const char *dom_sid,
id_t slice_num);
errno_t sysdb_idmap_get_mappings(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
struct ldb_result **_result);
#endif /* __SYS_DB_H__ */