sysdb.h revision 684d1b48b5582a1bf7812b8c3c663592dc6dfed9
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly System Database Header
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu Copyright (C) Simo Sorce <ssorce@redhat.com> 2008
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly This program is free software; you can redistribute it and/or modify
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly it under the terms of the GNU General Public License as published by
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly the Free Software Foundation; either version 3 of the License, or
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly (at your option) any later version.
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly This program is distributed in the hope that it will be useful,
53bd0c89aa4743dc41a6394db5a90717c1ca4517Liam O'Reilly but WITHOUT ANY WARRANTY; without even the implied warranty of
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9aeda2b3ae8ce0b018955521e4ca835a8ba8a27bLiam O'Reilly GNU General Public License for more details.
66bc8d6e69cde43f1ccbeb76104cf7b8038acd6cChristian Maeder You should have received a copy of the GNU General Public License
66bc8d6e69cde43f1ccbeb76104cf7b8038acd6cChristian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_NETGROUP_CONTAINER "cn=Netgroups"
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder#define SYSDB_TMPL_USER_BASE SYSDB_USERS_CONTAINER",cn=%s,"SYSDB_BASE
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_TMPL_GROUP_BASE SYSDB_GROUPS_CONTAINER",cn=%s,"SYSDB_BASE
fa373bc327620e08861294716b4454be8d25669fChristian Maeder#define SYSDB_TMPL_CUSTOM_BASE SYSDB_CUSTOM_CONTAINER",cn=%s,"SYSDB_BASE
036ecbd8f721096321f47cf6a354a9d1bf3d032fChristian Maeder#define SYSDB_TMPL_NETGROUP_BASE SYSDB_NETGROUP_CONTAINER",cn=%s,"SYSDB_BASE
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_LAST_ONLINE_AUTH "lastOnlineAuth"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_LAST_FAILED_LOGIN "lastFailedLogin"
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maeder#define SYSDB_FAILED_LOGIN_ATTEMPTS "failedLoginAttempts"
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_CACHE_EXPIRE "dataExpireTimestamp"
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_INITGR_EXPIRE "initgrExpireTimestamp"
fa373bc327620e08861294716b4454be8d25669fChristian Maeder#define SYSDB_AUTHORIZED_SERVICE "authorizedService"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_AUTHORIZED_HOST "authorizedHost"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_NETGROUP_TRIPLE "netgroupTriple"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_ORIG_NETGROUP_MEMBER "originalMemberNisNetgroup"
fa373bc327620e08861294716b4454be8d25669fChristian Maeder#define SYSDB_NETGROUP_MEMBER "memberNisNetgroup"
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_ORIG_MODSTAMP "originalModifyTimestamp"
e7cd36335f0f7be9ed5005e71d94c2856b588d62Christian Maeder#define SYSDB_NEXTID_FILTER "("SYSDB_NEXTID"=*)"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_UC "objectclass="SYSDB_USER_CLASS
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_GC "objectclass="SYSDB_GROUP_CLASS
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_NC "objectclass="SYSDB_NETGROUP_CLASS
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_PWNAM_FILTER "(&("SYSDB_UC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_PWUID_FILTER "(&("SYSDB_UC")("SYSDB_UIDNUM"=%lu))"
d5833d2ee7bafcbf2fdd2bdfd9a728c769b100c7Christian Maeder#define SYSDB_GRNAM_FILTER "(&("SYSDB_GC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
c0833539c8cf577dd3f2497792fbdd818442744cChristian Maeder#define SYSDB_GRNA2_FILTER "(&("SYSDB_UC")("SYSDB_MEMBEROF"=%s))"
c0833539c8cf577dd3f2497792fbdd818442744cChristian Maeder#define SYSDB_GRGID_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=%lu))"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_GRNAM_MPG_FILTER "(&("SYSDB_MPGC")(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_GRGID_MPG_FILTER "(&("SYSDB_MPGC")("SYSDB_GIDNUM"=%lu))"
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_GRENT_MPG_FILTER "("SYSDB_MPGC")"
c0833539c8cf577dd3f2497792fbdd818442744cChristian Maeder#define SYSDB_INITGR_FILTER "(&("SYSDB_GC")("SYSDB_GIDNUM"=*))"
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder#define SYSDB_GETCACHED_FILTER "(&"SYSDB_UC")("SYSDB_LAST_LOGIN">=%lu))"
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder#define SYSDB_NETGR_FILTER "(&("SYSDB_NC")("SYSDB_NAME"=%s))"
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_NETGR_TRIPLES_FILTER "(|("SYSDB_NAME"=%s)("SYSDB_MEMBEROF"=%s))"
eb48217dfa67ddb87b8fbd846de293d0636bd578Christian Maeder#define SYSDB_HAS_ENUMERATED "has_enumerated"
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_DEFAULT_ATTRS SYSDB_LAST_UPDATE, \
4314e26a12954cb1c9be4dea10aa8103edac5bbbChristian Maeder#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
ebd23ec61635b0bebf7969d14f65b9d1e39f2b26Liam O'Reilly#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_GRPW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
33bdce26495121cdbce30331ef90a1969126a840Liam O'Reilly#define SYSDB_GRENT_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, SYSDB_MEMBEROF, \
648fe1220044aac847acbdfbc4155af5556063ebChristian Maeder#define SYSDB_NETGR_ATTRS {SYSDB_NAME, SYSDB_NETGROUP_TRIPLE, \
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_INITGR_ATTRS {SYSDB_GIDNUM, SYSDB_POSIX, \
2a5b885d9350ec6dd8bc4992ee91d2f68aa592f4Christian Maeder#define SYSDB_TMPL_USER SYSDB_NAME"=%s,"SYSDB_TMPL_USER_BASE
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_TMPL_GROUP SYSDB_NAME"=%s,"SYSDB_TMPL_GROUP_BASE
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_TMPL_NETGROUP SYSDB_NAME"=%s,"SYSDB_TMPL_NETGROUP_BASE
7857a35e3af533dfbd0f0e18638ebd211e6358a0Christian Maeder#define SYSDB_TMPL_CUSTOM_SUBTREE "cn=%s,"SYSDB_TMPL_CUSTOM_BASE
7830e8fa7442fb7452af7ecdba102bc297ae367eChristian Maeder#define SYSDB_TMPL_CUSTOM SYSDB_NAME"=%s,cn=%s,"SYSDB_TMPL_CUSTOM_BASE
f21c7417bdd1c0282025cba0f5cb0ff5bc5c98eeLiam O'Reilly/* sysdb_attrs helper functions */
f21c7417bdd1c0282025cba0f5cb0ff5bc5c98eeLiam O'Reillystruct sysdb_attrs *sysdb_new_attrs(TALLOC_CTX *mem_ctx);
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder/* values are copied in the structure, allocated on "attrs" */
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroederint sysdb_attrs_add_val(struct sysdb_attrs *attrs,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maeder const char *name, const struct ldb_val *val);
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroederint sysdb_attrs_add_string(struct sysdb_attrs *attrs,
ee48a7a67da604356b665e51aa7545536a09b737Christian Maederint sysdb_attrs_add_bool(struct sysdb_attrs *attrs,
d381ab99d6e2e56e09030577d65d9a118f246d35Christian Maederint sysdb_attrs_add_long(struct sysdb_attrs *attrs,
ee48a7a67da604356b665e51aa7545536a09b737Christian Maederint sysdb_attrs_add_uint32(struct sysdb_attrs *attrs,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maederint sysdb_attrs_add_time_t(struct sysdb_attrs *attrs,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maederint sysdb_attrs_get_el(struct sysdb_attrs *attrs, const char *name,
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reillyint sysdb_attrs_steal_string(struct sysdb_attrs *attrs,
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reillyint sysdb_attrs_get_string(struct sysdb_attrs *attrs, const char *name,
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reilly const char **string);
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reillyint sysdb_attrs_get_string_array(struct sysdb_attrs *attrs, const char *name,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maedererrno_t sysdb_attrs_get_bool(struct sysdb_attrs *attrs, const char *name,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maederint sysdb_attrs_get_uint32_t(struct sysdb_attrs *attrs, const char *name,
7d96b1ef2b8597330aedee6713615ec15508edcfLiam O'Reillyint sysdb_attrs_replace_name(struct sysdb_attrs *attrs, const char *oldname,
7d96b1ef2b8597330aedee6713615ec15508edcfLiam O'Reilly const char *newname);
7d96b1ef2b8597330aedee6713615ec15508edcfLiam O'Reillyint sysdb_attrs_users_from_str_list(struct sysdb_attrs *attrs,
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reilly const char *const *list);
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reillyint sysdb_attrs_users_from_ldb_vals(struct sysdb_attrs *attrs,
bc350328e6ac2d9074317e222b4207a6aa49afeaLiam O'Reillyerrno_t sysdb_attrs_primary_name(struct sysdb_ctx *sysdb,
f19dc06364e8d6ea36f7c170e1f7a0677de63184Liam O'Reilly const char **_primary);
f19dc06364e8d6ea36f7c170e1f7a0677de63184Liam O'Reillyerrno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx,
ee48a7a67da604356b665e51aa7545536a09b737Christian Maedererrno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
45e2bc90dd11147156ddd7f9651ce8b2ec00f2a1Christian Maeder/* convert an ldb error into an errno error */
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maeder/* DNs related helper functions */
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maedererrno_t sysdb_get_rdn(struct sysdb_ctx *sysdb, void *mem_ctx,
b1f12c962a6fb28a298b36cf6a1dcf2ad788fb58Christian Maeder const char *_dn, char **_name, char **_val);
f19dc06364e8d6ea36f7c170e1f7a0677de63184Liam O'Reillystruct ldb_dn *sysdb_user_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_group_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_netgroup_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_netgroup_base_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maedererrno_t sysdb_group_dn_name(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_domain_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_custom_dn(struct sysdb_ctx *sysdb, void *mem_ctx,
fa373bc327620e08861294716b4454be8d25669fChristian Maeder const char *domain, const char *object_name,
fa373bc327620e08861294716b4454be8d25669fChristian Maederstruct ldb_dn *sysdb_custom_subtree_dn(struct sysdb_ctx *sysdb, void *mem_ctx,