summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-19 06:56:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:30 -0500
commit6bd8be867130686946e687512d7a4a68934217e1 (patch)
tree706672e72e96e9b2f676933273b448d0c49b5167 /source4/dsdb
parenta30726581e594013ae9b61a42dab813051999548 (diff)
downloadsamba-6bd8be867130686946e687512d7a4a68934217e1.tar.gz
samba-6bd8be867130686946e687512d7a4a68934217e1.tar.bz2
samba-6bd8be867130686946e687512d7a4a68934217e1.zip
r12360: Add simple bind support into our LDAP server.
Needs changes to our client code for automated testing. Andrew Bartlett (This used to be commit e751d814149d847ff1699542a4fa81eb8ca129ec)
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/cracknames.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index a377e3fe1d..c95ab047e3 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -850,3 +850,57 @@ NTSTATUS crack_service_principal_name(struct ldb_context *sam_ctx,
return NT_STATUS_OK;
}
+
+NTSTATUS crack_dn_to_nt4_name(TALLOC_CTX *mem_ctx,
+ const char *dn,
+ const char **nt4_domain, const char **nt4_account)
+{
+ WERROR werr;
+ struct drsuapi_DsNameInfo1 info1;
+ struct ldb_context *ldb;
+ char *p;
+
+ ldb = samdb_connect(mem_ctx, system_session(mem_ctx));
+ if (ldb == NULL) {
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ werr = DsCrackNameOneName(ldb, mem_ctx, 0,
+ DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
+ DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
+ dn,
+ &info1);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werror_to_ntstatus(werr);
+ }
+ switch (info1.status) {
+ case DRSUAPI_DS_NAME_STATUS_OK:
+ break;
+ case DRSUAPI_DS_NAME_STATUS_NOT_FOUND:
+ case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY:
+ case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE:
+ return NT_STATUS_NO_SUCH_USER;
+ case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR:
+ default:
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ *nt4_domain = talloc_strdup(mem_ctx, info1.result_name);
+
+ p = strchr(*nt4_domain, '\\');
+ if (!p) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ p[0] = '\0';
+
+ if (p[1]) {
+ *nt4_account = talloc_strdup(mem_ctx, &p[1]);
+ }
+
+ if (!*nt4_account || !*nt4_domain) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ return NT_STATUS_OK;
+
+}