summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-05-07 21:09:58 +0000
committerLuke Leighton <lkcl@samba.org>1998-05-07 21:09:58 +0000
commita4cc363d3ac2638015d78c54422c3cb3c76dfa3b (patch)
treed575481bc5ca54784ca07feba8394c8a38c94c3d /source3
parentb1ba33b3898b0fd4e67cb8f13655dc15989448b7 (diff)
downloadsamba-a4cc363d3ac2638015d78c54422c3cb3c76dfa3b.tar.gz
samba-a4cc363d3ac2638015d78c54422c3cb3c76dfa3b.tar.bz2
samba-a4cc363d3ac2638015d78c54422c3cb3c76dfa3b.zip
added first pass at start/get/end-ldappwent functions. unfortunately, lots
of information will be lost as these functions currently return struct smb_passwd not SAM_USER_INFO_21 or any other type of structure... (This used to be commit ad3097099cba524c9ec7c3ffc6d5647019efeaab)
Diffstat (limited to 'source3')
-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