svn commit: samba r2689 - in branches/SAMBA_4_0/source: ldap_server libcli/ldap

idra at samba.org idra at samba.org
Mon Sep 27 14:11:11 GMT 2004


Author: idra
Date: 2004-09-27 14:11:11 +0000 (Mon, 27 Sep 2004)
New Revision: 2689

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2689&nolog=1

Log:

Use consistent naming Del -> Delete
Add delete functionality to ldb simple lda server backend
add some const in ldap.h


Modified:
   branches/SAMBA_4_0/source/ldap_server/ldap_server.c
   branches/SAMBA_4_0/source/ldap_server/ldap_server.h
   branches/SAMBA_4_0/source/ldap_server/ldap_simple_ldb.c
   branches/SAMBA_4_0/source/libcli/ldap/ldap.c
   branches/SAMBA_4_0/source/libcli/ldap/ldap.h
   branches/SAMBA_4_0/source/libcli/ldap/ldap_ldif.c


Changeset:
Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.c
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.c	2004-09-27 14:11:11 UTC (rev 2689)
@@ -330,21 +330,21 @@
 	return part->ops->Add(part, call, req);
 }
 
-static NTSTATUS ldapsrv_DelRequest(struct ldapsrv_call *call)
+static NTSTATUS ldapsrv_DeleteRequest(struct ldapsrv_call *call)
 {
-	struct ldap_DelRequest *req = &call->request.r.DelRequest;
+	struct ldap_DeleteRequest *req = &call->request.r.DeleteRequest;
 	struct ldapsrv_partition *part;
 
-	DEBUG(10, ("DelRequest"));
+	DEBUG(10, ("DeleteRequest"));
 	DEBUGADD(10, (" dn: %s", req->dn));
 
 	part = ldapsrv_get_partition(call->conn, req->dn);
 
-	if (!part->ops->Del) {
+	if (!part->ops->Delete) {
 		return ldapsrv_unwilling(call, 53);
 	}
 
-	return part->ops->Del(part, call, req);
+	return part->ops->Delete(part, call, req);
 }
 
 static NTSTATUS ldapsrv_ModifyDNRequest(struct ldapsrv_call *call)
@@ -419,8 +419,8 @@
 		return ldapsrv_ModifyRequest(call);
 	case LDAP_TAG_AddRequest:
 		return ldapsrv_AddRequest(call);
-	case LDAP_TAG_DelRequest:
-		return ldapsrv_DelRequest(call);
+	case LDAP_TAG_DeleteRequest:
+		return ldapsrv_DeleteRequest(call);
 	case LDAP_TAG_ModifyDNRequest:
 		return ldapsrv_ModifyDNRequest(call);
 	case LDAP_TAG_CompareRequest:

Modified: branches/SAMBA_4_0/source/ldap_server/ldap_server.h
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_server.h	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_server.h	2004-09-27 14:11:11 UTC (rev 2689)
@@ -82,7 +82,7 @@
 	NTSTATUS (*Search)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_SearchRequest *r);
 	NTSTATUS (*Modify)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyRequest *r);
 	NTSTATUS (*Add)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AddRequest *r);
-	NTSTATUS (*Del)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_DelRequest *r);
+	NTSTATUS (*Delete)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_DeleteRequest *r);
 	NTSTATUS (*ModifyDN)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyDNRequest *r);
 	NTSTATUS (*Compare)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_CompareRequest *r);
 	NTSTATUS (*Abandon)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AbandonRequest *r);

Modified: branches/SAMBA_4_0/source/ldap_server/ldap_simple_ldb.c
===================================================================
--- branches/SAMBA_4_0/source/ldap_server/ldap_simple_ldb.c	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/ldap_server/ldap_simple_ldb.c	2004-09-27 14:11:11 UTC (rev 2689)
@@ -138,8 +138,51 @@
 	return ldapsrv_queue_reply(call, done_r);
 }
 
+static NTSTATUS sldb_Delete(struct ldapsrv_partition *partition, struct ldapsrv_call *call,
+				     struct ldap_DeleteRequest *r)
+{
+	struct ldap_Result *delete_result;
+	struct ldapsrv_reply *delete_reply;
+	int ldb_ret;
+	struct samdb_context *samdb;
+	struct ldb_context *ldb;
+
+	DEBUG(0, ("sldb_Delete: %s\n", r->dn));
+
+	samdb = samdb_connect(call);
+	ldb = samdb->ldb;
+
+	ldb_set_alloc(ldb, talloc_ldb_alloc, samdb);
+	ldb_ret = ldb_delete(ldb, r->dn);
+
+	delete_reply = ldapsrv_init_reply(call, LDAP_TAG_DeleteResponse);
+
+	delete_result = &delete_reply->msg.r.DeleteResponse;
+	delete_result->dn = talloc_steal(delete_reply, r->dn);
+
+	if (ldb_ret != 0) {
+		/* currently we have no way to tell if there was an internal ldb error
+		 * or if the object was not found, return the most probable error
+		 */
+		delete_result->resultcode = LDAP_NO_SUCH_OBJECT;
+		delete_result->errormessage = ldb_errstring(ldb);
+		delete_result->referral = NULL;
+	} else {	
+		delete_result->resultcode = LDAP_SUCCESS;
+		delete_result->errormessage = NULL;
+		delete_result->referral = NULL;
+	}
+
+	ldapsrv_queue_reply(call, delete_reply);
+
+	talloc_free(samdb);
+
+	return NT_STATUS_OK;
+}
+
 static const struct ldapsrv_partition_ops sldb_ops = {
-	.Search		= sldb_Search
+	.Search		= sldb_Search,
+	.Delete		= sldb_Delete
 };
 
 const struct ldapsrv_partition_ops *ldapsrv_get_sldb_partition_ops(void)

Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap.c	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap.c	2004-09-27 14:11:11 UTC (rev 2689)
@@ -547,16 +547,16 @@
 		ldap_encode_response(msg->type, r, &data);
 		break;
 	}
-	case LDAP_TAG_DelRequest: {
-		struct ldap_DelRequest *r = &msg->r.DelRequest;
+	case LDAP_TAG_DeleteRequest: {
+		struct ldap_DeleteRequest *r = &msg->r.DeleteRequest;
 		asn1_push_tag(&data,
-			      ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest));
+			      ASN1_APPLICATION_SIMPLE(LDAP_TAG_DeleteRequest));
 		asn1_write(&data, r->dn, strlen(r->dn));
 		asn1_pop_tag(&data);
 		break;
 	}
-	case LDAP_TAG_DelResponse: {
-		struct ldap_Result *r = &msg->r.DelResponse;
+	case LDAP_TAG_DeleteResponse: {
+		struct ldap_Result *r = &msg->r.DeleteResponse;
 		ldap_encode_response(msg->type, r, &data);
 		break;
 	}
@@ -1009,13 +1009,13 @@
 		break;
 	}
 
-	case ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest): {
-		struct ldap_DelRequest *r = &msg->r.DelRequest;
+	case ASN1_APPLICATION_SIMPLE(LDAP_TAG_DeleteRequest): {
+		struct ldap_DeleteRequest *r = &msg->r.DeleteRequest;
 		int len;
 		char *dn;
-		msg->type = LDAP_TAG_DelRequest;
+		msg->type = LDAP_TAG_DeleteRequest;
 		asn1_start_tag(data,
-			       ASN1_APPLICATION_SIMPLE(LDAP_TAG_DelRequest));
+			       ASN1_APPLICATION_SIMPLE(LDAP_TAG_DeleteRequest));
 		len = asn1_tag_remaining(data);
 		dn = talloc(msg->mem_ctx, len+1);
 		if (dn == NULL)
@@ -1027,11 +1027,11 @@
 		break;
 	}
 
-	case ASN1_APPLICATION(LDAP_TAG_DelResponse): {
-		struct ldap_Result *r = &msg->r.DelResponse;
-		msg->type = LDAP_TAG_DelResponse;
+	case ASN1_APPLICATION(LDAP_TAG_DeleteResponse): {
+		struct ldap_Result *r = &msg->r.DeleteResponse;
+		msg->type = LDAP_TAG_DeleteResponse;
 		ldap_decode_response(msg->mem_ctx, data,
-				     LDAP_TAG_DelResponse, r);
+				     LDAP_TAG_DeleteResponse, r);
 		break;
 	}
 

Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap.h	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap.h	2004-09-27 14:11:11 UTC (rev 2689)
@@ -33,8 +33,8 @@
 	LDAP_TAG_ModifyResponse = 7,
 	LDAP_TAG_AddRequest = 8,
 	LDAP_TAG_AddResponse = 9,
-	LDAP_TAG_DelRequest = 10,
-	LDAP_TAG_DelResponse = 11,
+	LDAP_TAG_DeleteRequest = 10,
+	LDAP_TAG_DeleteResponse = 11,
 	LDAP_TAG_ModifyDNRequest = 12,
 	LDAP_TAG_ModifyDNResponse = 13,
 	LDAP_TAG_CompareRequest = 14,
@@ -53,6 +53,7 @@
 enum ldap_result_code {
 	LDAP_SUCCESS = 0,
 	LDAP_SASL_BIND_IN_PROGRESS = 0x0e,
+	LDAP_NO_SUCH_OBJECT = 0x20,
 	LDAP_INVALID_CREDENTIALS = 0x31,
 	LDAP_OTHER = 0x50
 };
@@ -154,7 +155,7 @@
 	struct ldap_attribute *attributes;
 };
 
-struct ldap_DelRequest {
+struct ldap_DeleteRequest {
 	const char *dn;
 };
 
@@ -198,8 +199,8 @@
 	struct ldap_Result 		ModifyResponse;
 	struct ldap_AddRequest 		AddRequest;
 	struct ldap_Result 		AddResponse;
-	struct ldap_DelRequest 		DelRequest;
-	struct ldap_Result 		DelResponse;
+	struct ldap_DeleteRequest 	DeleteRequest;
+	struct ldap_Result 		DeleteResponse;
 	struct ldap_ModifyDNRequest 	ModifyDNRequest;
 	struct ldap_Result 		ModifyDNResponse;
 	struct ldap_CompareRequest 	CompareRequest;

Modified: branches/SAMBA_4_0/source/libcli/ldap/ldap_ldif.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/ldap/ldap_ldif.c	2004-09-27 13:20:59 UTC (rev 2688)
+++ branches/SAMBA_4_0/source/libcli/ldap/ldap_ldif.c	2004-09-27 14:11:11 UTC (rev 2689)
@@ -3,9 +3,6 @@
    LDAP protocol helper functions for SAMBA
    
    Copyright (C) Andrew Tridgell  2004
-   Copyright (C) Volker Lendecke 2004
-   Copyright (C) Stefan Metzmacher 2004
-   Copyright (C) Simo Sorce 2004
     
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -352,8 +349,8 @@
 	}
 
 	if (strequal(value.data, "delete")) {
-		msg->type = LDAP_TAG_DelRequest;
-		msg->r.DelRequest.dn = dn;
+		msg->type = LDAP_TAG_DeleteRequest;
+		msg->r.DeleteRequest.dn = dn;
 		return msg;
 	}
 



More information about the samba-cvs mailing list