summaryrefslogtreecommitdiff
path: root/source/libads
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-01-24 01:48:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:23 -0500
commitaaec0115e2c96935499052d9a637a20c6445986e (patch)
tree8686d22267022ee5d6c8fd98830bd6268bd2481c /source/libads
parent2a7311db272b5a504e2db672d92adbb3cf2bea15 (diff)
downloadsamba-aaec0115e2c96935499052d9a637a20c6445986e.tar.gz
r20986: Commit the prototype of the nss_info plugin interface.
This allows a provider to supply the homedirectory, etc... attributes for a user without requiring support in core winbindd code. The idmap_ad.c module has been modified to provide the idmap 'ad' library as well as the rfc2307 and sfu "winbind nss info" support. The SID/id mapping is working in idmap_ad but the nss_info still has a few quirks that I'm in the process of resolving.
Diffstat (limited to 'source/libads')
-rw-r--r--source/libads/ads_struct.c6
-rw-r--r--source/libads/ldap_schema.c77
2 files changed, 32 insertions, 51 deletions
diff --git a/source/libads/ads_struct.c b/source/libads/ads_struct.c
index 545995ddccc..05f066c9fa5 100644
--- a/source/libads/ads_struct.c
+++ b/source/libads/ads_struct.c
@@ -161,12 +161,6 @@ void ads_destroy(ADS_STRUCT **ads)
SAFE_FREE((*ads)->config.server_site_name);
SAFE_FREE((*ads)->config.client_site_name);
- SAFE_FREE((*ads)->schema.posix_uidnumber_attr);
- SAFE_FREE((*ads)->schema.posix_gidnumber_attr);
- SAFE_FREE((*ads)->schema.posix_shell_attr);
- SAFE_FREE((*ads)->schema.posix_homedir_attr);
- SAFE_FREE((*ads)->schema.posix_gecos_attr);
-
ZERO_STRUCTP(*ads);
if ( is_mine )
diff --git a/source/libads/ldap_schema.c b/source/libads/ldap_schema.c
index b4a512cbfe2..5d91d985490 100644
--- a/source/libads/ldap_schema.c
+++ b/source/libads/ldap_schema.c
@@ -186,7 +186,10 @@ static ADS_STATUS ads_schema_path(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char **s
* @return ADS_STATUS status of search (False if one or more attributes couldn't be
* found in Active Directory)
**/
-ADS_STATUS ads_check_posix_schema_mapping(ADS_STRUCT *ads, enum wb_posix_mapping map_type)
+ADS_STATUS ads_check_posix_schema_mapping(TALLOC_CTX *mem_ctx,
+ ADS_STRUCT *ads,
+ enum wb_posix_mapping map_type,
+ struct posix_schema **s )
{
TALLOC_CTX *ctx = NULL;
ADS_STATUS status;
@@ -194,6 +197,7 @@ ADS_STATUS ads_check_posix_schema_mapping(ADS_STRUCT *ads, enum wb_posix_mapping
size_t num_names;
char *schema_path = NULL;
int i;
+ struct posix_schema *schema = NULL;
const char *oids_sfu[] = { ADS_ATTR_SFU_UIDNUMBER_OID,
ADS_ATTR_SFU_GIDNUMBER_OID,
@@ -209,34 +213,15 @@ ADS_STATUS ads_check_posix_schema_mapping(ADS_STRUCT *ads, enum wb_posix_mapping
DEBUG(10,("ads_check_posix_schema_mapping\n"));
- switch (map_type) {
-
- case WB_POSIX_MAP_TEMPLATE:
- case WB_POSIX_MAP_UNIXINFO:
- DEBUG(10,("ads_check_posix_schema_mapping: nothing to do\n"));
- return ADS_ERROR(LDAP_SUCCESS);
-
- case WB_POSIX_MAP_SFU:
- case WB_POSIX_MAP_RFC2307:
- break;
-
- default:
- DEBUG(0,("ads_check_posix_schema_mapping: "
- "unknown enum %d\n", map_type));
- return ADS_ERROR(LDAP_PARAM_ERROR);
+ if ( (ctx = talloc_init("ads_check_posix_schema_mapping")) == NULL ) {
+ return ADS_ERROR(LDAP_NO_MEMORY);
}
- ads->schema.posix_uidnumber_attr = NULL;
- ads->schema.posix_gidnumber_attr = NULL;
- ads->schema.posix_homedir_attr = NULL;
- ads->schema.posix_shell_attr = NULL;
- ads->schema.posix_gecos_attr = NULL;
-
- ctx = talloc_init("ads_check_posix_schema_mapping");
- if (ctx == NULL) {
+ if ( (schema = TALLOC_P(mem_ctx, struct posix_schema)) == NULL ) {
+ TALLOC_FREE( ctx );
return ADS_ERROR(LDAP_NO_MEMORY);
}
-
+
status = ads_schema_path(ads, ctx, &schema_path);
if (!ADS_ERR_OK(status)) {
DEBUG(3,("ads_check_posix_mapping: Unable to retrieve schema DN!\n"));
@@ -257,10 +242,7 @@ ADS_STATUS ads_check_posix_schema_mapping(ADS_STRUCT *ads, enum wb_posix_mapping
DEBUG(3,("ads_check_posix_schema_mapping: failed %s\n",
ads_errstr(status)));
goto done;
- }
-
- DEBUG(10,("ads_check_posix_schema_mapping: query succeeded, identified: %s\n",
- wb_posix_map_str(map_type)));
+ }
for (i=0; i<num_names; i++) {
@@ -268,43 +250,48 @@ ADS_STATUS ads_check_posix_schema_mapping(ADS_STRUCT *ads, enum wb_posix_mapping
if (strequal(ADS_ATTR_RFC2307_UIDNUMBER_OID, oids_out[i]) ||
strequal(ADS_ATTR_SFU_UIDNUMBER_OID, oids_out[i])) {
- SAFE_FREE(ads->schema.posix_uidnumber_attr);
- ads->schema.posix_uidnumber_attr = SMB_STRDUP(names_out[i]);
+ schema->posix_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])) {
- SAFE_FREE(ads->schema.posix_gidnumber_attr);
- ads->schema.posix_gidnumber_attr = SMB_STRDUP(names_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])) {
- SAFE_FREE(ads->schema.posix_homedir_attr);
- ads->schema.posix_homedir_attr = SMB_STRDUP(names_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])) {
- SAFE_FREE(ads->schema.posix_shell_attr);
- ads->schema.posix_shell_attr = SMB_STRDUP(names_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])) {
- SAFE_FREE(ads->schema.posix_gecos_attr);
- ads->schema.posix_gecos_attr = SMB_STRDUP(names_out[i]);
+ schema->posix_gecos_attr = talloc_strdup(schema, names_out[i]);
}
}
- if (!ads->schema.posix_uidnumber_attr ||
- !ads->schema.posix_gidnumber_attr ||
- !ads->schema.posix_homedir_attr ||
- !ads->schema.posix_shell_attr ||
- !ads->schema.posix_gecos_attr) {
+ 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);
- ads->schema.map_type = map_type;
done:
if (ctx) {
talloc_destroy(ctx);