summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/replication/repl_bind.c
blob: e317e31166eb3356aaef7f9f48b66702f4d906b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
 

#include "slapi-plugin.h"
#include "repl.h"
#include "repl5.h"


int
legacy_preop_bind( Slapi_PBlock *pb )
{
    int return_value = 0;
	char *dn = NULL;
	struct berval *cred = NULL;
	int method;
	int one = 1;
    
	slapi_pblock_get(pb, SLAPI_BIND_METHOD, &method);
	slapi_pblock_get(pb, SLAPI_BIND_TARGET, &dn);
	slapi_pblock_get(pb, SLAPI_BIND_CREDENTIALS, &cred);

	if (LDAP_AUTH_SIMPLE == method)
	{
		if (legacy_consumer_is_replicationdn(dn) && legacy_consumer_is_replicationpw(cred))
		{
			/* Successful bind as replicationdn */
			void *conn = NULL;
			consumer_connection_extension *connext = NULL;
#ifdef DEBUG
	slapi_log_error(SLAPI_LOG_REPL, REPLICATION_SUBSYSTEM, "legacy_preop_bind: begin\n");
#endif
			slapi_pblock_get( pb, SLAPI_CONNECTION, &conn );
			connext = (consumer_connection_extension*) repl_con_get_ext (REPL_CON_EXT_CONN, conn);
			if (NULL != connext)
			{
				connext->is_legacy_replication_dn = 1;
			}
			slapi_send_ldap_result(pb, LDAP_SUCCESS, NULL, NULL, 0, NULL);
			return_value = 1; /* Prevent further processing in front end */
		}
	}
	return return_value;

}