1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-30 20:23:49 +03:00

This patch works towards to goal of common code shared between idmap_ldap

and pdb_ldap.

So far, it's just a function rename, so that the next patch can be a very
simple matter of copying functions, without worrying about what changed
in the process.

Also removes the 'static' pointers for the rebind procedures, replacing them
with a linked list of value/key lookups.  (Only needed on older LDAP client
libs)

Andrew Bartlett
This commit is contained in:
Andrew Bartlett
-
parent fa8ca20ed4
commit f93167a7e1
4 changed files with 391 additions and 281 deletions

View File

@@ -92,6 +92,18 @@ typedef struct _attrib_map_entry {
const char *name;
} ATTRIB_MAP_ENTRY;
struct smbldap_state {
LDAP *ldap_struct;
time_t last_ping;
/* retrive-once info */
const char *uri;
char *bind_dn;
char *bind_secret;
unsigned int num_failures;
};
/* structures */
extern ATTRIB_MAP_ENTRY attrib_map_v22[];
@@ -109,8 +121,7 @@ const char* get_attr_key2string( ATTRIB_MAP_ENTRY table[], int key );
char** get_attr_list( ATTRIB_MAP_ENTRY table[] );
void free_attr_list( char **list );
BOOL fetch_ldap_pw(char **dn, char** pw);
void ldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value);
void smbldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value);
#endif /* _SMBLDAP_H */

View File

@@ -262,7 +262,7 @@ BOOL fetch_ldap_pw(char **dn, char** pw)
manage memory used by the array, by each struct, and values
***********************************************************************/
void ldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value)
void smbldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value)
{
LDAPMod **mods;
int i;
@@ -344,3 +344,4 @@ void ldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const
*modlist = mods;
}

File diff suppressed because it is too large Load Diff

View File

@@ -575,8 +575,8 @@ static NTSTATUS ldap_allocate_id(unid_t *id, int id_type)
snprintf(new_id_str, sizeof(new_id_str), "%u",
((id_type & ID_USERID) ? id->uid : id->gid) + 1);
ldap_set_mod( &mods, LDAP_MOD_DELETE, type, id_str );
ldap_set_mod( &mods, LDAP_MOD_ADD, type, new_id_str );
smbldap_set_mod( &mods, LDAP_MOD_DELETE, type, id_str );
smbldap_set_mod( &mods, LDAP_MOD_ADD, type, new_id_str );
rc = ldap_modify_s(ldap_state.ldap_struct, dn, mods);
@@ -829,9 +829,9 @@ static NTSTATUS ldap_set_mapping(const DOM_SID *sid, unid_t id, int id_type)
snprintf(id_str, sizeof(id_str), "%u", ((id_type & ID_USERID) ? id.uid : id.gid));
sid_to_string( sid_str, sid );
ldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_IDMAP_ENTRY );
ldap_set_mod( &mods, LDAP_MOD_ADD, type, id_str );
ldap_set_mod( &mods, LDAP_MOD_ADD,
smbldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_IDMAP_ENTRY );
smbldap_set_mod( &mods, LDAP_MOD_ADD, type, id_str );
smbldap_set_mod( &mods, LDAP_MOD_ADD,
get_attr_key2string(sidmap_attr_list, LDAP_ATTR_SID), sid_str );
do {
@@ -910,10 +910,10 @@ static NTSTATUS ldap_idmap_init( char *params )
snprintf( uid_str, sizeof(uid_str), "%d", luid );
snprintf( gid_str, sizeof(gid_str), "%d", lgid );
ldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_IDPOOL );
ldap_set_mod( &mods, LDAP_MOD_ADD,
smbldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_IDPOOL );
smbldap_set_mod( &mods, LDAP_MOD_ADD,
get_attr_key2string(idpool_attr_list, LDAP_ATTR_UIDNUMBER), uid_str );
ldap_set_mod( &mods, LDAP_MOD_ADD,
smbldap_set_mod( &mods, LDAP_MOD_ADD,
get_attr_key2string(idpool_attr_list, LDAP_ATTR_GIDNUMBER), gid_str );
do {
@@ -931,15 +931,15 @@ static NTSTATUS ldap_idmap_init( char *params )
mods = NULL;
snprintf( dn, sizeof(dn), "%s,%s", IDMAP_USER_SUFFIX, lp_ldap_idmap_suffix() );
ldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_OU );
ldap_set_mod( &mods, LDAP_MOD_ADD, "ou", "idmap people" );
smbldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_OU );
smbldap_set_mod( &mods, LDAP_MOD_ADD, "ou", "idmap people" );
ldap_add_s(ldap_state.ldap_struct, dn, mods);
ldap_mods_free( mods, True );
mods = NULL;
snprintf( dn, sizeof(dn), "%s,%s", IDMAP_GROUP_SUFFIX, lp_ldap_idmap_suffix() );
ldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_OU );
ldap_set_mod( &mods, LDAP_MOD_ADD, "ou", "idmap group" );
smbldap_set_mod( &mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_OU );
smbldap_set_mod( &mods, LDAP_MOD_ADD, "ou", "idmap group" );
ldap_add_s(ldap_state.ldap_struct, dn, mods);
ldap_mods_free( mods, True );
#endif