mirror of
https://github.com/haiwen/ccnet-server.git
synced 2025-05-10 08:04:22 +00:00
Merge pull request #30 from haiwen/ldap_get_user_in_list
get_emailusers_in_list() can get ldap users.
This commit is contained in:
commit
d649953073
@ -198,7 +198,7 @@ ccnet_start_rpc(CcnetSession *session)
|
||||
searpc_server_register_function ("ccnet-threaded-rpcserver",
|
||||
ccnet_rpc_get_emailusers_in_list,
|
||||
"get_emailusers_in_list",
|
||||
searpc_signature_objlist__string());
|
||||
searpc_signature_objlist__string_string());
|
||||
|
||||
/* RSA sign a message with my private key. */
|
||||
searpc_server_register_function ("ccnet-rpcserver",
|
||||
@ -1705,15 +1705,15 @@ ccnet_rpc_get_groups_members (const char *group_ids, GError **error)
|
||||
}
|
||||
|
||||
GList *
|
||||
ccnet_rpc_get_emailusers_in_list(const char *user_list, GError **error)
|
||||
ccnet_rpc_get_emailusers_in_list(const char *source, const char *user_list, GError **error)
|
||||
{
|
||||
if (!user_list) {
|
||||
if (!user_list || !source) {
|
||||
g_set_error (error, CCNET_DOMAIN, CCNET_ERR_INTERNAL, "Bad arguments");
|
||||
return NULL;
|
||||
}
|
||||
CcnetUserManager *user_mgr = ((CcnetServerSession *)session)->user_mgr;
|
||||
|
||||
return ccnet_user_manager_get_emailusers_in_list (user_mgr, user_list, error);
|
||||
return ccnet_user_manager_get_emailusers_in_list (user_mgr, source, user_list, error);
|
||||
}
|
||||
|
||||
#endif /* CCNET_SERVER */
|
||||
|
@ -329,7 +329,7 @@ char *
|
||||
ccnet_rpc_get_primary_id (const char *email, GError **error);
|
||||
|
||||
GList *
|
||||
ccnet_rpc_get_emailusers_in_list(const char *user_list, GError **error);
|
||||
ccnet_rpc_get_emailusers_in_list(const char *source, const char *user_list, GError **error);
|
||||
|
||||
#endif /* CCNET_SERVER */
|
||||
|
||||
|
@ -1904,6 +1904,7 @@ ccnet_user_manager_get_login_id (CcnetUserManager *manager, const char *primary_
|
||||
|
||||
GList *
|
||||
ccnet_user_manager_get_emailusers_in_list (CcnetUserManager *manager,
|
||||
const char *source,
|
||||
const char *user_list,
|
||||
GError **error)
|
||||
{
|
||||
@ -1927,11 +1928,6 @@ ccnet_user_manager_get_emailusers_in_list (CcnetUserManager *manager,
|
||||
return NULL;
|
||||
}
|
||||
GString *sql = g_string_new ("");
|
||||
g_string_printf (sql, "SELECT e.id, e.email, is_staff, is_active, ctime, "
|
||||
"role, passwd FROM EmailUser e "
|
||||
"LEFT JOIN UserRole r ON e.email = r.email "
|
||||
"WHERE e.email IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
if (i < user_num) {
|
||||
j_obj = json_array_get (j_array, i);
|
||||
@ -1941,6 +1937,36 @@ ccnet_user_manager_get_emailusers_in_list (CcnetUserManager *manager,
|
||||
args[i] = "";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LDAP
|
||||
if (manager->use_ldap) {
|
||||
if (strcmp (source, "LDAP") == 0) {
|
||||
g_string_printf (sql, "SELECT l.id, l.email, is_staff, is_active, role "
|
||||
"FROM LDAPUsers l LEFT JOIN UserRole r "
|
||||
"ON l.email = r.email "
|
||||
"WHERE l.email IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
if (ccnet_db_statement_foreach_row (manager->priv->db, sql->str, get_ldap_emailusers_cb, &ret, 20,
|
||||
"string", args[0], "string", args[1], "string", args[2],
|
||||
"string", args[3], "string", args[4], "string", args[5],
|
||||
"string", args[6], "string", args[7], "string", args[8],
|
||||
"string", args[9], "string", args[10], "string", args[11],
|
||||
"string", args[12], "string", args[13], "string", args[14],
|
||||
"string", args[15], "string", args[16], "string", args[17],
|
||||
"string", args[18], "string", args[19]) < 0)
|
||||
ccnet_warning("Failed to get users in list %s.\n", user_list);
|
||||
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (strcmp (source, "DB") != 0)
|
||||
goto out;
|
||||
|
||||
g_string_printf (sql, "SELECT e.id, e.email, is_staff, is_active, ctime, "
|
||||
"role, passwd FROM EmailUser e "
|
||||
"LEFT JOIN UserRole r ON e.email = r.email "
|
||||
"WHERE e.email IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
|
||||
if (ccnet_db_statement_foreach_row (manager->priv->db, sql->str, get_emailusers_cb, &ret, 20,
|
||||
"string", args[0], "string", args[1], "string", args[2],
|
||||
"string", args[3], "string", args[4], "string", args[5],
|
||||
@ -1951,6 +1977,7 @@ ccnet_user_manager_get_emailusers_in_list (CcnetUserManager *manager,
|
||||
"string", args[18], "string", args[19]) < 0)
|
||||
ccnet_warning("Failed to get users in list %s.\n", user_list);
|
||||
|
||||
out:
|
||||
json_decref (j_array);
|
||||
g_string_free (sql, TRUE);
|
||||
|
||||
|
@ -171,6 +171,7 @@ ccnet_user_manager_get_login_id (CcnetUserManager *manager,
|
||||
|
||||
GList *
|
||||
ccnet_user_manager_get_emailusers_in_list (CcnetUserManager *manager,
|
||||
const char *source,
|
||||
const char *user_list,
|
||||
GError **error);
|
||||
#endif
|
||||
|
@ -451,6 +451,6 @@ class CcnetThreadedRpcClient(RpcClientBase):
|
||||
def get_groups_members(self, group_ids):
|
||||
pass
|
||||
|
||||
@searpc_func("objlist", ["string"])
|
||||
def get_emailusers_in_list(self, user_list):
|
||||
@searpc_func("objlist", ["string", "string"])
|
||||
def get_emailusers_in_list(self, source, user_list):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user