-/*
+/*
Unix SMB/CIFS implementation.
Samba utility functions
objectSid being in domain_sid.
*/
int samdb_search_domain(struct ldb_context *sam_ldb,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
struct ldb_dn *basedn,
struct ldb_message ***res,
const char * const *attrs,
attrs[0] = attr_name;
count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
- if (count > 1) {
- DEBUG(1,("samdb: search for %s %s not single valued (count=%d)\n",
+ if (count > 1) {
+ DEBUG(1,("samdb: search for %s %s not single valued (count=%d)\n",
attr_name, format, count));
}
if (count != 1) {
va_start(ap, format);
count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
va_end(ap);
- if (count > 1) {
- DEBUG(1,("samdb: search for %s %s not single valued (count=%d)\n",
+ if (count > 1) {
+ DEBUG(1,("samdb: search for %s %s not single valued (count=%d)\n",
attr_name, format, count));
}
if (count != 1) {
}
sid = samdb_result_dom_sid(mem_ctx, res[0], attr_name);
talloc_free(res);
- return sid;
+ return sid;
}
/*
/* make sure its single valued */
for (i=0;i<count;i++) {
if (res[i]->num_elements != 1) {
- DEBUG(1,("samdb: search for %s %s not single valued\n",
+ DEBUG(1,("samdb: search for %s %s not single valued\n",
attr_name, format));
talloc_free(res);
return -1;
}
/*
- pull a rid from a objectSid in a result set.
+ pull a rid from a objectSid in a result set.
*/
-uint32_t samdb_result_rid_from_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
+uint32_t samdb_result_rid_from_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
const char *attr, uint32_t default_value)
{
struct dom_sid *sid;
}
/*
- pull a dom_sid structure from a objectSid in a result set.
+ pull a dom_sid structure from a objectSid in a result set.
*/
-struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
+struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
const char *attr)
{
ssize_t ret;
}
/*
- pull a guid structure from a objectGUID in a result set.
+ pull a guid structure from a objectGUID in a result set.
*/
struct GUID samdb_result_guid(const struct ldb_message *msg, const char *attr)
{
}
/*
- pull a sid prefix from a objectSid in a result set.
+ pull a sid prefix from a objectSid in a result set.
this is used to find the domain sid for a user
*/
-struct dom_sid *samdb_result_sid_prefix(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
+struct dom_sid *samdb_result_sid_prefix(TALLOC_CTX *mem_ctx, const struct ldb_message *msg,
const char *attr)
{
struct dom_sid *sid = samdb_result_dom_sid(mem_ctx, msg, attr);
}
/*
- pull a NTTIME in a result set.
+ pull a NTTIME in a result set.
*/
NTTIME samdb_result_nttime(const struct ldb_message *msg, const char *attr,
NTTIME default_value)
}
/*
- construct the allow_password_change field from the PwdLastSet attribute and the
+ construct the allow_password_change field from the PwdLastSet attribute and the
domain password settings
*/
-NTTIME samdb_result_allow_password_change(struct ldb_context *sam_ldb,
- TALLOC_CTX *mem_ctx,
- struct ldb_dn *domain_dn,
- struct ldb_message *msg,
+NTTIME samdb_result_allow_password_change(struct ldb_context *sam_ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *domain_dn,
+ struct ldb_message *msg,
const char *attr)
{
uint64_t attr_time = ldb_msg_find_attr_as_uint64(msg, attr, 0);
}
/*
- pull a samr_Password structutre from a result set.
+ pull a samr_Password structutre from a result set.
*/
struct samr_Password *samdb_result_hash(TALLOC_CTX *mem_ctx, const struct ldb_message *msg, const char *attr)
{
}
/*
- pull a samr_LogonHours structutre from a result set.
+ pull a samr_LogonHours structutre from a result set.
*/
struct samr_LogonHours samdb_result_logon_hours(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr)
{
}
/*
- pull a set of account_flags from a result set.
+ pull a set of account_flags from a result set.
Naturally, this requires that userAccountControl and
(if not null) the attributes 'attr' be already
* behaviour: In particular, objectClass subclass equivalence is not
* wanted. This means that we should not lookup the schema for the
* comparison function */
-struct ldb_message_element *samdb_find_attribute(struct ldb_context *ldb,
- const struct ldb_message *msg,
+struct ldb_message_element *samdb_find_attribute(struct ldb_context *ldb,
+ const struct ldb_message *msg,
const char *name, const char *value)
{
unsigned int i;
struct ldb_val v;
enum ndr_err_code ndr_err;
- ndr_err = ndr_push_struct_blob(&v, mem_ctx,
+ ndr_err = ndr_push_struct_blob(&v, mem_ctx,
sid,
(ndr_push_flags_fn_t)ndr_push_dom_sid);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
int samdb_msg_add_delete(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name)
{
- /* we use an empty replace rather than a delete, as it allows for
+ /* we use an empty replace rather than a delete, as it allows for
dsdb_replace() to be used everywhere */
return ldb_msg_add_empty(msg, attr_name, LDB_FLAG_MOD_REPLACE, NULL);
}
return sd;
}
-struct ldb_dn *samdb_aggregate_schema_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx)
+struct ldb_dn *samdb_aggregate_schema_dn(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx)
{
struct ldb_dn *schema_dn = ldb_get_schema_basedn(sam_ctx);
struct ldb_dn *aggregate_dn;
struct dom_sid *dom_sid_old;
/* see if we have a cached copy */
- dom_sid_old = talloc_get_type(ldb_get_opaque(ldb,
+ dom_sid_old = talloc_get_type(ldb_get_opaque(ldb,
"cache.domain_sid"), struct dom_sid);
tmp_ctx = talloc_new(ldb);
struct ldb_dn *ntds_settings_dn_old;
/* see if we have a forced copy from provision */
- ntds_settings_dn_old = talloc_get_type(ldb_get_opaque(ldb,
+ ntds_settings_dn_old = talloc_get_type(ldb_get_opaque(ldb,
"forced.ntds_settings_dn"), struct ldb_dn);
tmp_ctx = talloc_new(ldb);
ret = ldb_search(ldb, tmp_ctx, &root_res, ldb_dn_new(tmp_ctx, ldb, ""), LDB_SCOPE_BASE, root_attrs, NULL);
if (ret != LDB_SUCCESS) {
- DEBUG(1,("Searching for dsServiceName in rootDSE failed: %s\n",
+ DEBUG(1,("Searching for dsServiceName in rootDSE failed: %s\n",
ldb_errstring(ldb)));
goto failed;
}
dn = ldb_dn_get_parent(mem_ctx, samdb_ntds_settings_dn(ldb, tmp_ctx));
talloc_free(tmp_ctx);
return dn;
-
+
}
/*
}
ret = samdb_dn_is_our_ntdsa(ldb, referenced_dn, is_ntdsa);
-
+
talloc_free(tmp_ctx);
return ret;
}
int ret;
bool is_pdc;
- ret = samdb_reference_dn_is_our_ntdsa(ldb, ldb_get_default_basedn(ldb), "fsmoRoleOwner",
+ ret = samdb_reference_dn_is_our_ntdsa(ldb, ldb_get_default_basedn(ldb), "fsmoRoleOwner",
&is_pdc);
if (ret != LDB_SUCCESS) {
- DEBUG(1,("Failed to find if we are the PDC for this ldb: Searching for fSMORoleOwner in %s failed: %s\n",
- ldb_dn_get_linearized(ldb_get_default_basedn(ldb)),
+ DEBUG(1,("Failed to find if we are the PDC for this ldb: Searching for fSMORoleOwner in %s failed: %s\n",
+ ldb_dn_get_linearized(ldb_get_default_basedn(ldb)),
ldb_errstring(ldb)));
return false;
}
const struct samr_Password *ntNewHash,
enum dsdb_password_checked old_password_checked,
enum samPwdChangeReason *reject_reason,
- struct samr_DomInfo1 **_dominfo)
+ struct samr_DomInfo1 **_dominfo)
{
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS nt_status;
}
-NTSTATUS samdb_create_foreign_security_principal(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
- struct dom_sid *sid, struct ldb_dn **ret_dn)
+NTSTATUS samdb_create_foreign_security_principal(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
+ struct dom_sid *sid, struct ldb_dn **ret_dn)
{
struct ldb_message *msg;
struct ldb_dn *basedn = NULL;
ret = ldb_add(sam_ctx, msg);
if (ret != LDB_SUCCESS) {
DEBUG(0,("Failed to create foreignSecurityPrincipal "
- "record %s: %s\n",
+ "record %s: %s\n",
ldb_dn_get_linearized(msg->dn),
ldb_errstring(sam_ctx)));
talloc_free(sidstr);
Find the DN of a domain, assuming it to be a dotted.dns name
*/
-struct ldb_dn *samdb_dns_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *dns_domain)
+struct ldb_dn *samdb_dns_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *dns_domain)
{
unsigned int i;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
/*
- Find the DN of a domain, be it the netbios or DNS name
+ Find the DN of a domain, be it the netbios or DNS name
*/
-struct ldb_dn *samdb_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
- const char *domain_name)
+struct ldb_dn *samdb_domain_to_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+ const char *domain_name)
{
const char * const domain_ref_attrs[] = {
"ncName", NULL
char *escaped_domain = ldb_binary_encode_string(mem_ctx, domain_name);
/* find the domain's DN */
int ret_domain = ldb_search(ldb, mem_ctx,
- &res_domain_ref,
- samdb_partitions_dn(ldb, mem_ctx),
- LDB_SCOPE_ONELEVEL,
+ &res_domain_ref,
+ samdb_partitions_dn(ldb, mem_ctx),
+ LDB_SCOPE_ONELEVEL,
domain_ref_attrs,
- "(&(nETBIOSName=%s)(objectclass=crossRef))",
+ "(&(nETBIOSName=%s)(objectclass=crossRef))",
escaped_domain);
if (ret_domain != LDB_SUCCESS) {
return NULL;
if (res_domain_ref->count == 0) {
ret_domain = ldb_search(ldb, mem_ctx,
- &res_domain_ref,
+ &res_domain_ref,
samdb_dns_domain_to_dn(ldb, mem_ctx, domain_name),
LDB_SCOPE_BASE,
domain_ref2_attrs,
}
if (res_domain_ref->count > 1) {
- DEBUG(0,("Found %d records matching domain [%s]\n",
+ DEBUG(0,("Found %d records matching domain [%s]\n",
ret_domain, domain_name));
return NULL;
}
/*
use a GUID to find a DN
*/
-int dsdb_find_dn_by_guid(struct ldb_context *ldb,
+int dsdb_find_dn_by_guid(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
const struct GUID *guid,
uint32_t dsdb_flags,
/*
use a DN to find a SID
*/
-int dsdb_find_sid_by_dn(struct ldb_context *ldb,
+int dsdb_find_sid_by_dn(struct ldb_context *ldb,
struct ldb_dn *dn, struct dom_sid *sid)
{
int ret;
for (i=0; i<(*count); i++) {
enum ndr_err_code ndr_err;
- ndr_err = ndr_pull_struct_blob(&el->values[i],
- mem_ctx,
- &(*r)[i],
+ ndr_err = ndr_pull_struct_blob(&el->values[i],
+ mem_ctx,
+ &(*r)[i],
(ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
}
talloc_free(tmp_ctx);
-
+
return WERR_OK;
}
struct ldb_val v;
enum ndr_err_code ndr_err;
- ndr_err = ndr_push_struct_blob(&v, tmp_ctx,
- &r[i],
+ ndr_err = ndr_push_struct_blob(&v, tmp_ctx,
+ &r[i],
(ndr_push_flags_fn_t)ndr_push_repsFromToBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
goto failed;
}
talloc_free(tmp_ctx);
-
+
return WERR_OK;
failed:
}
p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
p_ctrl->dn = dn;
-
+
ret = ldb_request_add_control(req,
DSDB_CONTROL_CURRENT_PARTITION_OID,
false, p_ctrl);
talloc_free(tmp_ctx);
return ret;
}
-
+
/* Run the new request */
ret = ldb_request(ldb, req);
-
+
if (ret == LDB_SUCCESS) {
ret = ldb_wait(req->handle, LDB_WAIT_ALL);
}
talloc_free(tmp_ctx);
- return LDB_SUCCESS;
+ return LDB_SUCCESS;
}
int drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplicaCursor2 *c1,
}
/*
- return NTDS options flags. See MS-ADTS 7.1.1.2.2.1.2.1.1
+ return NTDS options flags. See MS-ADTS 7.1.1.2.2.1.2.1.1
flags are DS_NTDS_OPTION_*
*/
}
if (dsdb_flags & DSDB_PASSWORD_BYPASS_LAST_SET) {
- /*
+ /*
* This must not be critical, as it will only be
* handled (and need to be handled) if the other
* attributes in the request bring password_hash into