summaryrefslogtreecommitdiffstats
path: root/source3/winbindd/idmap_util.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@us.ibm.com>2013-02-21 12:30:48 -0700
committerAndrew Bartlett <abartlet@samba.org>2013-03-09 06:30:22 +0100
commit86d09ce779fdc9d6ebbbe44b25656808ab37ee14 (patch)
tree5a967ad323207002cbe61d88395b53e8c4b03306 /source3/winbindd/idmap_util.c
parent666a5630ef3b03640089a0b6e81bf578b91b88ab (diff)
downloadsamba-86d09ce779fdc9d6ebbbe44b25656808ab37ee14.tar.gz
samba-86d09ce779fdc9d6ebbbe44b25656808ab37ee14.tar.xz
samba-86d09ce779fdc9d6ebbbe44b25656808ab37ee14.zip
s3-winbindd: Move common code for LDAP id mapping to idmap_utils
idmap_ad and idmap_ldap use the same helper functions and the same maximum query size. Move the code to idmap_utils so that it can be shared by every module issuing LDAP queries. Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/winbindd/idmap_util.c')
-rw-r--r--source3/winbindd/idmap_util.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c
index 9d9ada71999..cbad91d151e 100644
--- a/source3/winbindd/idmap_util.c
+++ b/source3/winbindd/idmap_util.c
@@ -172,3 +172,44 @@ bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom)
return true;
}
+
+/**
+ * Helper for unixids_to_sids: find entry by id in mapping array,
+ * search up to IDMAP_AD_MAX_IDS entries
+ */
+struct id_map *idmap_find_map_by_id(struct id_map **maps, enum id_type type,
+ uint32_t id)
+{
+ int i;
+
+ for (i = 0; i < IDMAP_LDAP_MAX_IDS; i++) {
+ if (maps[i] == NULL) { /* end of the run */
+ return NULL;
+ }
+ if ((maps[i]->xid.type == type) && (maps[i]->xid.id == id)) {
+ return maps[i];
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Helper for sids_to_unix_ids: find entry by SID in mapping array,
+ * search up to IDMAP_AD_MAX_IDS entries
+ */
+struct id_map *idmap_find_map_by_sid(struct id_map **maps, struct dom_sid *sid)
+{
+ int i;
+
+ for (i = 0; i < IDMAP_LDAP_MAX_IDS; i++) {
+ if (maps[i] == NULL) { /* end of the run */
+ return NULL;
+ }
+ if (dom_sid_equal(maps[i]->sid, sid)) {
+ return maps[i];
+ }
+ }
+
+ return NULL;
+}