[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1364-g38995d7
Andrew Tridgell
tridge at samba.org
Thu Sep 3 03:15:50 MDT 2009
The branch, master has been updated
via 38995d7cbb0c3143eb1fea0215863321349c7bbe (commit)
via 957a9285c22c5f4412154bd84a82d66fe759b0f5 (commit)
via 47dfe78142c89fd8798d22d5837d9b3be356ae78 (commit)
from d3d6713c599fa74f5fdd890bd00ab0dd721749d8 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 38995d7cbb0c3143eb1fea0215863321349c7bbe
Author: Anatoliy Atanasov <anatoliy.atanasov at postpath.com>
Date: Wed Sep 2 17:39:28 2009 +0300
First attempt to implement dcesrv_drsuapi_DsGetNCChanges
So far it returns the ctr6 responce without proper linked attributes
support and metadata. A couple of improvements are the filter in the search
uses '(uSNChanged>=N)', added extended dn search support, non-replicated attributes
are excluded from the result.
commit 957a9285c22c5f4412154bd84a82d66fe759b0f5
Author: Anatoliy Atanasov <anatoliy.atanasov at postpath.com>
Date: Wed Sep 2 17:20:16 2009 +0300
Fix the dsdb_syntax_OID_ldb_to_drsuapi function
This replace the dsdb_syntax_FOOBAR_ldb_to_drsuapi function,
which was left as a TODO code. Implementation in both added functions
is completely identical and probably should differ in the future.
commit 47dfe78142c89fd8798d22d5837d9b3be356ae78
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date: Fri Aug 21 14:39:09 2009 +0300
Ignoring generated files:
libcli/smb/smb_common_proto.h
source4/torture/ntp/proto.h
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 +
source4/dsdb/schema/schema_syntax.c | 52 +++++++-
source4/rpc_server/drsuapi/dcesrv_drsuapi.c | 205 ++++++++++++++++++++++++++-
3 files changed, 257 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/.gitignore b/.gitignore
index 6ff72a0..8d671d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -189,6 +189,7 @@ source4/libcli/finddcs.h
source4/libcli/ldap/ldap_proto.h
source4/libcli/libcli_proto.h
libcli/nbt/nbtname.h
+libcli/smb/smb_common_proto.h
source4/libcli/nbt/nbt_proto.h
source4/libcli/ndr_netlogon_proto.h
source4/libcli/netlogon_proto.h
@@ -289,6 +290,7 @@ source4/torture/local/proto.h
source4/torture/nbench/proto.h
source4/torture/nbt/proto.h
source4/torture/ndr/proto.h
+source4/torture/ntp/proto.h
source4/torture/proto.h
source4/torture/rap/proto.h
source4/torture/raw/proto.h
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index 2f14e3c..33a43cf 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -660,6 +660,55 @@ static WERROR _dsdb_syntax_OID_oid_drsuapi_to_ldb(struct ldb_context *ldb,
return WERR_OK;
}
+static WERROR _dsdb_syntax_OID_obj_ldb_to_drsuapi(struct ldb_context *ldb,
+ const struct dsdb_schema *schema,
+ const struct dsdb_attribute *attr,
+ const struct ldb_message_element *in,
+ TALLOC_CTX *mem_ctx,
+ struct drsuapi_DsReplicaAttribute *out)
+{
+ uint32_t i;
+ DATA_BLOB *blobs;
+
+ out->attid= attr->attributeID_id;
+ out->value_ctr.num_values= in->num_values;
+ out->value_ctr.values= talloc_array(mem_ctx,
+ struct drsuapi_DsAttributeValue,
+ in->num_values);
+ W_ERROR_HAVE_NO_MEMORY(out->value_ctr.values);
+
+ blobs = talloc_array(mem_ctx, DATA_BLOB, in->num_values);
+ W_ERROR_HAVE_NO_MEMORY(blobs);
+
+ for (i=0; i < in->num_values; i++) {
+ const struct dsdb_class *obj_class;
+
+ out->value_ctr.values[i].blob= &blobs[i];
+
+ blobs[i] = data_blob_talloc(blobs, NULL, 4);
+ W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
+
+ obj_class = dsdb_class_by_lDAPDisplayName(schema, (const char *)in->values[i].data);
+ if (!obj_class) {
+ return WERR_FOOBAR;
+ }
+ SIVAL(blobs[i].data, 0, obj_class->governsID_id);
+ }
+
+
+ return WERR_OK;
+}
+
+static WERROR _dsdb_syntax_OID_oid_ldb_to_drsuapi(struct ldb_context *ldb,
+ const struct dsdb_schema *schema,
+ const struct dsdb_attribute *attr,
+ const struct ldb_message_element *in,
+ TALLOC_CTX *mem_ctx,
+ struct drsuapi_DsReplicaAttribute *out)
+{
+ return _dsdb_syntax_OID_obj_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
+}
+
static WERROR dsdb_syntax_OID_drsuapi_to_ldb(struct ldb_context *ldb,
const struct dsdb_schema *schema,
const struct dsdb_attribute *attr,
@@ -731,10 +780,11 @@ static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
switch (attr->attributeID_id) {
case DRSUAPI_ATTRIBUTE_objectClass:
+ return _dsdb_syntax_OID_obj_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
case DRSUAPI_ATTRIBUTE_governsID:
case DRSUAPI_ATTRIBUTE_attributeID:
case DRSUAPI_ATTRIBUTE_attributeSyntax:
- return dsdb_syntax_FOOBAR_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
+ return _dsdb_syntax_OID_oid_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
}
out->attid = attr->attributeID_id;
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
index 6af8ea5..3fef3eb 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
@@ -236,6 +236,66 @@ static WERROR dcesrv_drsuapi_DsReplicaSync(struct dcesrv_call_state *dce_call, T
return WERR_OK;
}
+int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_result **_res,
+ struct ldb_dn *basedn,
+ enum ldb_scope scope,
+ const char * const *attrs,
+ const char *format, ...)
+{
+ va_list ap;
+ int ret;
+ struct ldb_request *req;
+ char *filter;
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_result *res;
+
+ tmp_ctx = talloc_new(mem_ctx);
+
+ res = talloc_zero(tmp_ctx, struct ldb_result);
+ if (!res) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ va_start(ap, format);
+ filter = talloc_vasprintf(tmp_ctx, format, ap);
+ va_end(ap);
+
+ if (filter == NULL) {
+ talloc_free(tmp_ctx);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ret = ldb_build_search_req(&req, ldb, tmp_ctx,
+ basedn,
+ scope,
+ filter,
+ attrs,
+ NULL,
+ res,
+ ldb_search_default_callback,
+ NULL);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+
+ ret = ldb_request_add_control(req, LDB_CONTROL_EXTENDED_DN_OID, true, NULL);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ ret = ldb_request(ldb, req);
+ if (ret == LDB_SUCCESS) {
+ ret = ldb_wait(req->handle, LDB_WAIT_ALL);
+ }
+
+ talloc_free(req);
+ *_res = res;
+ return ret;
+}
+
/*
drsuapi_DsGetNCChanges
@@ -243,7 +303,150 @@ static WERROR dcesrv_drsuapi_DsReplicaSync(struct dcesrv_call_state *dce_call, T
static WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct drsuapi_DsGetNCChanges *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ struct ldb_result *site_res;
+ struct drsuapi_DsReplicaObjectIdentifier *ncRoot;
+ struct drsuapi_bind_state *b_state;
+ struct ldb_dn *ncRoot_dn;
+ int ret;
+ int i;
+ int j;
+ int uSN;
+ struct dsdb_schema *schema;
+ struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
+ time_t t = time(NULL);
+ NTTIME now;
+ struct drsuapi_DsReplicaObjectListItemEx *currentObject;
+ struct dom_sid *zero_sid;
+ struct ldb_dn *obj_dn;
+
+ b_state = talloc_zero(mem_ctx, struct drsuapi_bind_state);
+ W_ERROR_HAVE_NO_MEMORY(b_state);
+ zero_sid = talloc_zero(mem_ctx, struct dom_sid);
+ /*
+ * connect to the samdb
+ */
+ b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ if (!b_state->sam_ctx) {
+ return WERR_FOOBAR;
+ }
+
+ /* Check request revision. */
+ if (r->in.level != 8) {
+ return WERR_REVISION_MISMATCH;
+ }
+
+ /* Perform access checks. */
+ if (r->in.req->req8.naming_context == NULL) {
+ return WERR_DS_DRA_INVALID_PARAMETER;
+ }
+
+ ncRoot = r->in.req->req8.naming_context;
+ if (ncRoot == NULL) {
+ return WERR_DS_DRA_BAD_NC;
+ }
+
+ /* Construct response. */
+ ncRoot_dn = ldb_dn_new(mem_ctx, b_state->sam_ctx, ncRoot->dn);
+ ret = drsuapi_search_with_extended_dn(b_state->sam_ctx, mem_ctx, &site_res,
+ ncRoot_dn, LDB_SCOPE_SUBTREE, NULL,
+ "(&(uSNChanged>=%lld)(objectClass=*))", r->in.req->req8.highwatermark.highest_usn);
+ if (ret != LDB_SUCCESS) {
+ return WERR_DS_DRA_INTERNAL_ERROR;
+ }
+
+ *r->out.level_out = 6;
+ r->out.ctr->ctr6.naming_context = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
+ *r->out.ctr->ctr6.naming_context = *ncRoot;
+ /* TODO: linked attributes*/
+ r->out.ctr->ctr6.linked_attributes_count = 0;
+ r->out.ctr->ctr6.linked_attributes = NULL;
+
+ r->out.ctr->ctr6.object_count = 0;
+ r->out.ctr->ctr6.more_data = false;
+ r->out.ctr->ctr6.uptodateness_vector = NULL;
+
+ /* Prefix mapping */
+ schema = dsdb_get_schema(b_state->sam_ctx);
+ if (!schema) {
+ DEBUG(0,("No schema in b_state->sam_ctx"));
+ }
+
+ dsdb_get_oid_mappings_drsuapi(schema, true, mem_ctx, &ctr);
+ r->out.ctr->ctr6.mapping_ctr = *ctr;
+
+ r->out.ctr->ctr6.source_dsa_guid = *(samdb_ntds_objectGUID(b_state->sam_ctx));
+ r->out.ctr->ctr6.source_dsa_invocation_id = *(samdb_ntds_invocation_id(b_state->sam_ctx));
+
+ r->out.ctr->ctr6.old_highwatermark = r->in.req->req8.highwatermark;
+ r->out.ctr->ctr6.new_highwatermark = r->in.req->req8.highwatermark;
+
+ r->out.ctr->ctr6.first_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx);
+ currentObject = r->out.ctr->ctr6.first_object;
+
+ for(i=0; i<site_res->count; i++) {
+ uSN = ldb_msg_find_attr_as_int(site_res->msgs[i],"uSNChanged", -1);
+ r->out.ctr->ctr6.object_count++;
+ if (uSN > r->out.ctr->ctr6.new_highwatermark.highest_usn) {
+ r->out.ctr->ctr6.new_highwatermark.highest_usn = uSN;
+ }
+
+ if (ldb_dn_compare(ncRoot_dn, site_res->msgs[i]->dn) == 0) {
+ currentObject->is_nc_prefix = true;
+ currentObject->parent_object_guid = NULL;
+ } else {
+ currentObject->is_nc_prefix = false;
+ currentObject->parent_object_guid = talloc(mem_ctx, struct GUID);
+ *currentObject->parent_object_guid = samdb_result_guid(site_res->msgs[i], "parentGUID");
+ }
+ currentObject->next_object = NULL;
+ /* TODO: MetaData vector*/
+ currentObject->meta_data_ctr = talloc(mem_ctx, struct drsuapi_DsReplicaMetaDataCtr);
+ currentObject->meta_data_ctr->meta_data = talloc(mem_ctx, struct drsuapi_DsReplicaMetaData);
+ currentObject->meta_data_ctr->count = 0;
+ currentObject->object.identifier = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
+ obj_dn = ldb_msg_find_attr_as_dn(b_state->sam_ctx, mem_ctx, site_res->msgs[i], "distinguishedName");
+ currentObject->object.identifier->dn = ldb_dn_get_linearized(obj_dn);
+ currentObject->object.identifier->guid = GUID_zero();
+ currentObject->object.identifier->sid = *zero_sid;
+
+ currentObject->object.attribute_ctr.num_attributes = site_res->msgs[i]->num_elements;
+ /* Exclude non-replicate attributes from the responce.*/
+ for (j=0; j<site_res->msgs[i]->num_elements; j++) {
+ const struct dsdb_attribute *sa;
+ sa = dsdb_attribute_by_lDAPDisplayName(schema, site_res->msgs[i]->elements[j].name);
+ if (sa && sa->systemFlags & 0x00000001) {
+ ldb_msg_remove_attr(site_res->msgs[i], site_res->msgs[i]->elements[j].name);
+ currentObject->object.attribute_ctr.num_attributes--;
+ }
+ }
+ currentObject->object.attribute_ctr.attributes = talloc_array(mem_ctx, struct drsuapi_DsReplicaAttribute,
+ currentObject->object.attribute_ctr.num_attributes);
+ for (j=0; j<currentObject->object.attribute_ctr.num_attributes; j++) {
+ dsdb_attribute_ldb_to_drsuapi(b_state->sam_ctx, schema,&site_res->msgs[i]->elements[j], mem_ctx,
+ ¤tObject->object.attribute_ctr.attributes[j]);
+ }
+
+ if (i == (site_res->count-1)) {
+ break;
+ }
+ currentObject->next_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx);
+ currentObject = currentObject->next_object;
+ }
+
+ r->out.ctr->ctr6.uptodateness_vector = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2CtrEx);
+
+ r->out.ctr->ctr6.uptodateness_vector->version = 2;
+ r->out.ctr->ctr6.uptodateness_vector->count = 1;
+ r->out.ctr->ctr6.uptodateness_vector->reserved1 = 0;
+ r->out.ctr->ctr6.uptodateness_vector->reserved2 = 0;
+ r->out.ctr->ctr6.uptodateness_vector->cursors = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2);
+
+ r->out.ctr->ctr6.uptodateness_vector->cursors[0].source_dsa_invocation_id = *(samdb_ntds_invocation_id(b_state->sam_ctx));
+ r->out.ctr->ctr6.uptodateness_vector->cursors[0].highest_usn = r->out.ctr->ctr6.new_highwatermark.highest_usn;
+ unix_to_nt_time(&now, t);
+ r->out.ctr->ctr6.uptodateness_vector->cursors[0].last_sync_success = now;
+
+ return WERR_OK;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list