summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-07-04 11:09:42 +0200
committerVolker Lendecke <vl@samba.org>2009-07-04 12:54:23 +0200
commitbfd82e49791a91c20e581dacd6ba8fa43b9efce6 (patch)
tree4f3cf74bec80944e6054b5d4974c7ef5c0736370 /source3/passdb
parent5742ed128df90db400ff825bba7a939dadac8c30 (diff)
downloadsamba-bfd82e49791a91c20e581dacd6ba8fa43b9efce6.tar.gz
samba-bfd82e49791a91c20e581dacd6ba8fa43b9efce6.tar.bz2
samba-bfd82e49791a91c20e581dacd6ba8fa43b9efce6.zip
Add pdb_ads_get_domain_info
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_ads.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 7a2fac701b..ee6c695e75 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -70,9 +70,62 @@ struct pdb_ads_samu_private {
struct tldap_message *ldapmsg;
};
+static char *pdb_ads_domaindn2dns(TALLOC_CTX *mem_ctx, char *dn)
+{
+ char *result, *p;
+
+ result = talloc_string_sub2(mem_ctx, dn, "DC=", "", false, false,
+ true);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ while ((p = strchr_m(result, ',')) != NULL) {
+ *p = '.';
+ }
+
+ return result;
+}
+
static struct pdb_domain_info *pdb_ads_get_domain_info(
struct pdb_methods *m, TALLOC_CTX *mem_ctx)
{
+ struct pdb_ads_state *state = talloc_get_type_abort(
+ m->private_data, struct pdb_ads_state);
+ struct pdb_domain_info *info;
+ struct tldap_message *rootdse;
+ char *tmp;
+
+ info = talloc(mem_ctx, struct pdb_domain_info);
+ if (info == NULL) {
+ return NULL;
+ }
+ info->name = talloc_strdup(info, state->netbiosname);
+ if (info->name == NULL) {
+ goto fail;
+ }
+ info->dns_domain = pdb_ads_domaindn2dns(info, state->domaindn);
+ if (info->dns_domain == NULL) {
+ goto fail;
+ }
+
+ rootdse = tldap_rootdse(state->ld);
+ tmp = tldap_talloc_single_attribute(rootdse, "rootDomainNamingContext",
+ talloc_tos());
+ if (tmp == NULL) {
+ goto fail;
+ }
+ info->dns_forest = pdb_ads_domaindn2dns(info, tmp);
+ TALLOC_FREE(tmp);
+ if (info->dns_forest == NULL) {
+ goto fail;
+ }
+ info->sid = state->domainsid;
+ info->guid = state->domainguid;
+ return info;
+
+fail:
+ TALLOC_FREE(info);
return NULL;
}