From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- source3/libads/ldap_schema.c | 354 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 source3/libads/ldap_schema.c (limited to 'source3/libads/ldap_schema.c') diff --git a/source3/libads/ldap_schema.c b/source3/libads/ldap_schema.c new file mode 100644 index 0000000..d2f486e --- /dev/null +++ b/source3/libads/ldap_schema.c @@ -0,0 +1,354 @@ +/* + Unix SMB/CIFS implementation. + ads (active directory) utility library + Copyright (C) Guenther Deschner 2005-2007 + Copyright (C) Gerald (Jerry) Carter 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "ads.h" +#include "libads/ldap_schema.h" +#include "libads/ldap_schema_oids.h" +#include "../libcli/ldap/ldap_ndr.h" + +#ifdef HAVE_LDAP + +static ADS_STATUS ads_get_attrnames_by_oids(ADS_STRUCT *ads, + TALLOC_CTX *mem_ctx, + const char *schema_path, + const char **OIDs, + size_t num_OIDs, + char ***OIDs_out, char ***names, + size_t *count) +{ + ADS_STATUS status; + LDAPMessage *res = NULL; + LDAPMessage *msg; + char *expr = NULL; + const char *attrs[] = { "lDAPDisplayName", "attributeId", NULL }; + int i = 0, p = 0; + + if (!ads || !mem_ctx || !names || !count || !OIDs || !OIDs_out) { + return ADS_ERROR(LDAP_PARAM_ERROR); + } + + if (num_OIDs == 0 || OIDs[0] == NULL) { + return ADS_ERROR_NT(NT_STATUS_NONE_MAPPED); + } + + expr = talloc_asprintf(mem_ctx, "(|"); + + for (i=0; iposix_uidnumber_attr = talloc_strdup(schema, names_out[i]); + continue; + } + + if (strequal(ADS_ATTR_RFC2307_GIDNUMBER_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_GIDNUMBER_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_GIDNUMBER_OID, oids_out[i])) { + schema->posix_gidnumber_attr = talloc_strdup(schema, names_out[i]); + continue; + } + + if (strequal(ADS_ATTR_RFC2307_HOMEDIR_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_HOMEDIR_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_HOMEDIR_OID, oids_out[i])) { + schema->posix_homedir_attr = talloc_strdup(schema, names_out[i]); + continue; + } + + if (strequal(ADS_ATTR_RFC2307_SHELL_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_SHELL_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_SHELL_OID, oids_out[i])) { + schema->posix_shell_attr = talloc_strdup(schema, names_out[i]); + continue; + } + + if (strequal(ADS_ATTR_RFC2307_GECOS_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_GECOS_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_GECOS_OID, oids_out[i])) { + schema->posix_gecos_attr = talloc_strdup(schema, names_out[i]); + } + + if (strequal(ADS_ATTR_RFC2307_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU_UID_OID, oids_out[i]) || + strequal(ADS_ATTR_SFU20_UID_OID, oids_out[i])) { + schema->posix_uid_attr = talloc_strdup(schema, names_out[i]); + } + } + + if (!schema->posix_uidnumber_attr || + !schema->posix_gidnumber_attr || + !schema->posix_homedir_attr || + !schema->posix_shell_attr || + !schema->posix_gecos_attr) { + status = ADS_ERROR(LDAP_NO_MEMORY); + TALLOC_FREE( schema ); + goto done; + } + + *s = schema; + + status = ADS_ERROR(LDAP_SUCCESS); + +done: + TALLOC_FREE(ctx); + + return status; +} + +#endif -- cgit v1.2.3