summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_samr.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-09 15:20:13 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:08 +0200
commit488badb8acdb6bcf9135a3073b08e4f5526d73b0 (patch)
tree5e3a1560c52104b5a2820ed46a01bfac69462da0 /source3/winbindd/winbindd_samr.c
parent645ce68e357948c8bddf46e7b3777788af4d0a72 (diff)
downloadsamba-488badb8acdb6bcf9135a3073b08e4f5526d73b0.tar.gz
samba-488badb8acdb6bcf9135a3073b08e4f5526d73b0.tar.bz2
samba-488badb8acdb6bcf9135a3073b08e4f5526d73b0.zip
s3-winbind: Implemented samr backend function common_sequence_number.
Diffstat (limited to 'source3/winbindd/winbindd_samr.c')
-rw-r--r--source3/winbindd/winbindd_samr.c69
1 files changed, 65 insertions, 4 deletions
diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c
index b611602e8b..3815e13271 100644
--- a/source3/winbindd/winbindd_samr.c
+++ b/source3/winbindd/winbindd_samr.c
@@ -1402,11 +1402,73 @@ error:
static NTSTATUS common_sequence_number(struct winbindd_domain *domain,
uint32_t *seq)
{
- /* TODO FIXME */
- return NT_STATUS_NOT_IMPLEMENTED;
+ struct rpc_pipe_client *samr_pipe;
+ struct policy_handle dom_pol;
+ union samr_DomainInfo *info = NULL;
+ bool got_seq_num = false;
+ TALLOC_CTX *mem_ctx;
+ NTSTATUS status;
+
+ DEBUG(3,("samr: sequence number\n"));
+
+ mem_ctx = talloc_init("common_sequence_number");
+ if (mem_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (seq) {
+ *seq = DOM_SEQUENCE_NONE;
+ }
+
+ status = open_internal_samr_conn(mem_ctx, domain, &samr_pipe, &dom_pol);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto error;
+ }
+
+ /* query domain info */
+ status = rpccli_samr_QueryDomainInfo(samr_pipe,
+ mem_ctx,
+ &dom_pol,
+ 8,
+ &info);
+ if (NT_STATUS_IS_OK(status)) {
+ if (seq) {
+ *seq = info->info8.sequence_num;
+ got_seq_num = true;
+ }
+ goto seq_num;
+ }
+
+ /* retry with info-level 2 in case the dc does not support info-level 8
+ * (like all older samba2 and samba3 dc's) - Guenther */
+ status = rpccli_samr_QueryDomainInfo(samr_pipe,
+ mem_ctx,
+ &dom_pol,
+ 2,
+ &info);
+ if (NT_STATUS_IS_OK(status)) {
+ if (seq) {
+ *seq = info->general.sequence_num;
+ got_seq_num = true;
+ }
+ }
+
+seq_num:
+ if (got_seq_num) {
+ DEBUG(10,("domain_sequence_number: for domain %s is %u\n",
+ domain->name, (unsigned)*seq));
+ } else {
+ DEBUG(10,("domain_sequence_number: failed to get sequence "
+ "number (%u) for domain %s\n",
+ (unsigned) *seq, domain->name ));
+ status = NT_STATUS_OK;
+ }
+
+error:
+ talloc_destroy(mem_ctx);
+ return status;
}
-#if 0
/* the rpc backend methods are exposed via this structure */
struct winbindd_methods builtin_passdb_methods = {
.consistent = false,
@@ -1446,4 +1508,3 @@ struct winbindd_methods sam_passdb_methods = {
.password_policy = common_password_policy,
.trusted_domains = sam_trusted_domains
};
-#endif