summaryrefslogtreecommitdiff
path: root/source3/passdb/ldap.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/passdb/ldap.c')
-rw-r--r--source3/passdb/ldap.c75
1 files changed, 65 insertions, 10 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c
index 6146239a1c..1f0c846ad7 100644
--- a/source3/passdb/ldap.c
+++ b/source3/passdb/ldap.c
@@ -446,7 +446,7 @@ struct smb_passwd *getldappwnam(char *name)
struct smb_passwd *getldappwuid(unsigned int uid)
{
- return get_ldappwd_entry(NULL, uid);
+ return get_ldappwd_entry(NULL, uid);
}
/***************************************************************
@@ -456,16 +456,56 @@ struct smb_passwd *getldappwuid(unsigned int uid)
do not call this function directly. use passdb.c instead.
****************************************************************/
-void *startldappwent(BOOL update)
+
+struct ldap_enum_info
{
- return NULL;
-}
+ LDAP *ldap_struct;
+ LDAPMessage *result;
+ LDAPMessage *entry;
+};
-/***************************************************************
- End enumeration of the ldap passwd list.
-****************************************************************/
-void endldappwent(void *vp)
+static struct ldap_enum_info ldap_ent;
+
+void *startldappwent(BOOL update)
{
+ int scope = LDAP_SCOPE_ONELEVEL;
+ int rc;
+
+ char filter[256];
+
+ if (!ldap_open_connection(&ldap_ent.ldap_struct)) /* open a connection to the server */
+ return NULL;
+
+ if (!ldap_connect_system(ldap_ent.ldap_struct)) /* connect as system account */
+ return NULL;
+
+ /* when the class is known the search is much faster */
+ switch (0)
+ {
+ case 1:
+ {
+ strcpy(filter, "objectclass=sambaAccount");
+ break;
+ }
+ case 2:
+ {
+ strcpy(filter, "objectclass=sambaMachine");
+ break;
+ }
+ default:
+ {
+ strcpy(filter, "(|(objectclass=sambaMachine)(objectclass=sambaAccount))");
+ break;
+ }
+ }
+
+ rc=ldap_search_s(ldap_ent.ldap_struct, lp_ldap_suffix(), scope, filter, NULL, 0, &ldap_ent.result);
+
+ DEBUG(2,("%d entries in the base!\n", ldap_count_entries(ldap_ent.ldap_struct, ldap_ent.result) ));
+
+ ldap_ent.entry = ldap_first_entry(ldap_ent.ldap_struct, ldap_ent.result);
+
+ return &ldap_ent;
}
/*************************************************************************
@@ -476,7 +516,23 @@ void endldappwent(void *vp)
*************************************************************************/
struct smb_passwd *getldappwent(void *vp)
{
- return NULL;
+
+ struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
+ ldap_vp->entry = ldap_next_entry(ldap_vp->ldap_struct, ldap_vp->entry);
+/*
+ make_ldap_sam_user_info_21(ldap_struct, entry, &(pw_buf[(*num_entries)]) );
+*/
+ return NULL;
+}
+
+/***************************************************************
+ End enumeration of the ldap passwd list.
+****************************************************************/
+void endldappwent(void *vp)
+{
+ struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
+ ldap_msgfree(ldap_vp->result);
+ ldap_unbind(ldap_vp->ldap_struct);
}
/*************************************************************************
@@ -503,5 +559,4 @@ BOOL setldappwpos(void *vp, unsigned long tok)
return False;
}
-
#endif