summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-21 10:47:22 +0200
committerAndreas Schneider <asn@samba.org>2010-07-05 15:59:13 +0200
commitc4a5fc72c732e40c53b6206280ed9c22cc8f0fb1 (patch)
treea7734e91b891af46fbad002d4145a76915ef14c9
parent62038010e0cb74a0de8fe68c7566a6db153ea58b (diff)
downloadsamba-c4a5fc72c732e40c53b6206280ed9c22cc8f0fb1.tar.gz
samba-c4a5fc72c732e40c53b6206280ed9c22cc8f0fb1.tar.bz2
samba-c4a5fc72c732e40c53b6206280ed9c22cc8f0fb1.zip
s3-winbind: Added a common rpc_sequence_number function.
-rw-r--r--source3/winbindd/winbindd_rpc.c49
-rw-r--r--source3/winbindd/winbindd_rpc.h7
2 files changed, 56 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c
index a87f368d90..05638244ec 100644
--- a/source3/winbindd/winbindd_rpc.c
+++ b/source3/winbindd/winbindd_rpc.c
@@ -783,3 +783,52 @@ NTSTATUS rpc_lookup_groupmem(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+
+/* Find the sequence number for a domain */
+NTSTATUS rpc_sequence_number(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *samr_pipe,
+ struct policy_handle *samr_policy,
+ const char *domain_name,
+ uint32_t *pseq)
+{
+ union samr_DomainInfo *info = NULL;
+ bool got_seq_num = false;
+ NTSTATUS status;
+
+ /* query domain info */
+ status = rpccli_samr_QueryDomainInfo(samr_pipe,
+ mem_ctx,
+ samr_policy,
+ 8,
+ &info);
+ if (NT_STATUS_IS_OK(status)) {
+ *pseq = 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,
+ samr_policy,
+ 2,
+ &info);
+ if (NT_STATUS_IS_OK(status)) {
+ *pseq = 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) *pseq));
+ } else {
+ DEBUG(10,("domain_sequence_number: failed to get sequence "
+ "number (%u) for domain %s\n",
+ (unsigned) *pseq, domain_name ));
+ status = NT_STATUS_OK;
+ }
+
+ return status;
+}
diff --git a/source3/winbindd/winbindd_rpc.h b/source3/winbindd/winbindd_rpc.h
index b31718747f..fb1abd0575 100644
--- a/source3/winbindd/winbindd_rpc.h
+++ b/source3/winbindd/winbindd_rpc.h
@@ -117,4 +117,11 @@ NTSTATUS rpc_lookup_groupmem(TALLOC_CTX *mem_ctx,
char ***pnames,
uint32_t **pname_types);
+/* Find the sequence number for a domain */
+NTSTATUS rpc_sequence_number(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *samr_pipe,
+ struct policy_handle *samr_policy,
+ const char *domain_name,
+ uint32_t *pseq);
+
#endif /* _WINBINDD_RPC_H_ */