diff options
Diffstat (limited to 'source4/dsdb/samdb/samdb.c')
-rw-r--r-- | source4/dsdb/samdb/samdb.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index 17c40dd30d..7de873d77d 100644 --- a/source4/dsdb/samdb/samdb.c +++ b/source4/dsdb/samdb/samdb.c @@ -35,6 +35,7 @@ #include "db_wrap.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" +#include "param/param.h" /* connect to the SAM database @@ -44,7 +45,8 @@ struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx, struct auth_session_info *session_info) { struct ldb_context *ldb; - ldb = ldb_wrap_connect(mem_ctx, lp_sam_url(), session_info, + ldb = ldb_wrap_connect(mem_ctx, global_loadparm, + lp_sam_url(global_loadparm), session_info, NULL, 0, NULL); if (!ldb) { return NULL; @@ -449,9 +451,7 @@ struct dom_sid *samdb_result_sid_prefix(TALLOC_CTX *mem_ctx, const struct ldb_me */ NTTIME samdb_result_nttime(struct ldb_message *msg, const char *attr, NTTIME default_value) { - const char *str = ldb_msg_find_attr_as_string(msg, attr, NULL); - if (!str) return default_value; - return nttime_from_string(str); + return ldb_msg_find_attr_as_uint64(msg, attr, default_value); } /* @@ -637,17 +637,13 @@ struct ldb_message_element *samdb_find_attribute(struct ldb_context *ldb, { int i; struct ldb_message_element *el = ldb_msg_find_element(msg, name); - struct ldb_val v; - - v.data = discard_const_p(uint8_t, value); - v.length = strlen(value); if (!el) { return NULL; } for (i=0;i<el->num_values;i++) { - if (strcasecmp(value, (char *)el->values[i].data) == 0) { + if (ldb_attr_cmp(value, (char *)el->values[i].data) == 0) { return el; } } @@ -1072,7 +1068,7 @@ const struct dom_sid *samdb_domain_sid(struct ldb_context *ldb) struct dom_sid *domain_sid; /* see if we have a cached copy */ - domain_sid = ldb_get_opaque(ldb, "cache.domain_sid"); + domain_sid = (struct dom_sid *)ldb_get_opaque(ldb, "cache.domain_sid"); if (domain_sid) { return domain_sid; } @@ -1139,7 +1135,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb) struct ldb_dn *settings_dn; /* see if we have a cached copy */ - settings_dn = ldb_get_opaque(ldb, "cache.settings_dn"); + settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "cache.settings_dn"); if (settings_dn) { return settings_dn; } @@ -1192,7 +1188,7 @@ const struct GUID *samdb_ntds_invocation_id(struct ldb_context *ldb) struct GUID *invocation_id; /* see if we have a cached copy */ - invocation_id = ldb_get_opaque(ldb, "cache.invocation_id"); + invocation_id = (struct GUID *)ldb_get_opaque(ldb, "cache.invocation_id"); if (invocation_id) { return invocation_id; } @@ -1242,7 +1238,8 @@ bool samdb_set_ntds_invocation_id(struct ldb_context *ldb, const struct GUID *in struct GUID *invocation_id_old; /* see if we have a cached copy */ - invocation_id_old = ldb_get_opaque(ldb, "cache.invocation_id"); + invocation_id_old = (struct GUID *)ldb_get_opaque(ldb, + "cache.invocation_id"); tmp_ctx = talloc_new(ldb); if (tmp_ctx == NULL) { @@ -1285,7 +1282,7 @@ const struct GUID *samdb_ntds_objectGUID(struct ldb_context *ldb) struct GUID *ntds_guid; /* see if we have a cached copy */ - ntds_guid = ldb_get_opaque(ldb, "cache.ntds_guid"); + ntds_guid = (struct GUID *)ldb_get_opaque(ldb, "cache.ntds_guid"); if (ntds_guid) { return ntds_guid; } @@ -1335,7 +1332,7 @@ bool samdb_set_ntds_objectGUID(struct ldb_context *ldb, const struct GUID *ntds_ struct GUID *ntds_guid_old; /* see if we have a cached copy */ - ntds_guid_old = ldb_get_opaque(ldb, "cache.ntds_guid"); + ntds_guid_old = (struct GUID *)ldb_get_opaque(ldb, "cache.ntds_guid"); tmp_ctx = talloc_new(ldb); if (tmp_ctx == NULL) { @@ -1394,19 +1391,19 @@ struct ldb_dn *samdb_server_site_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx /* work out if we are the PDC for the domain of the current open ldb */ -BOOL samdb_is_pdc(struct ldb_context *ldb) +bool samdb_is_pdc(struct ldb_context *ldb) { const char *dom_attrs[] = { "fSMORoleOwner", NULL }; int ret; struct ldb_result *dom_res; TALLOC_CTX *tmp_ctx; - BOOL is_pdc; + bool is_pdc; struct ldb_dn *pdc; tmp_ctx = talloc_new(ldb); if (tmp_ctx == NULL) { DEBUG(1, ("talloc_new failed in samdb_is_pdc")); - return False; + return false; } ret = ldb_search(ldb, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res); @@ -1424,9 +1421,9 @@ BOOL samdb_is_pdc(struct ldb_context *ldb) pdc = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, dom_res->msgs[0], "fSMORoleOwner"); if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc) == 0) { - is_pdc = True; + is_pdc = true; } else { - is_pdc = False; + is_pdc = false; } talloc_free(tmp_ctx); @@ -1436,7 +1433,7 @@ BOOL samdb_is_pdc(struct ldb_context *ldb) failed: DEBUG(1,("Failed to find if we are the PDC for this ldb\n")); talloc_free(tmp_ctx); - return False; + return false; } @@ -1477,7 +1474,7 @@ struct ldb_dn *samdb_search_for_parent_domain(struct ldb_context *ldb, TALLOC_CT /* check that a password is sufficiently complex */ -static BOOL samdb_password_complexity_ok(const char *pass) +static bool samdb_password_complexity_ok(const char *pass) { return check_password_quality(pass); } @@ -1503,7 +1500,7 @@ _PUBLIC_ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ct const char *new_pass, struct samr_Password *lmNewHash, struct samr_Password *ntNewHash, - BOOL user_change, + bool user_change, enum samr_RejectReason *reject_reason, struct samr_DomInfo1 **_dominfo) { @@ -1524,7 +1521,7 @@ _PUBLIC_ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ct int sambaLMPwdHistory_len, sambaNTPwdHistory_len; struct dom_sid *domain_sid; struct ldb_message **res; - BOOL restrictions; + bool restrictions; int count; time_t now = time(NULL); NTTIME now_nt; @@ -1741,7 +1738,7 @@ _PUBLIC_ NTSTATUS samdb_set_password_sid(struct ldb_context *ctx, TALLOC_CTX *me const char *new_pass, struct samr_Password *lmNewHash, struct samr_Password *ntNewHash, - BOOL user_change, + bool user_change, enum samr_RejectReason *reject_reason, struct samr_DomInfo1 **_dominfo) { @@ -1814,7 +1811,7 @@ NTSTATUS security_token_create(TALLOC_CTX *mem_ctx, struct dom_sid *group_sid, int n_groupSIDs, struct dom_sid **groupSIDs, - BOOL is_authenticated, + bool is_authenticated, struct security_token **token) { struct security_token *ptoken; |