2 Unix SMB/CIFS implementation.
4 endpoint server for the drsuapi pipe
7 Copyright (C) Stefan Metzmacher 2004
8 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "librpc/gen_ndr/drsuapi.h"
26 #include "rpc_server/common/common.h"
27 #include "lib/events/events.h"
28 #include "lib/ldb/include/ldb.h"
29 #include "lib/ldb/include/ldb_errors.h"
30 #include "system/kerberos.h"
31 #include "auth/kerberos/kerberos.h"
32 #include "libcli/ldap/ldap_ndr.h"
33 #include "libcli/security/security.h"
34 #include "librpc/gen_ndr/ndr_misc.h"
35 #include "auth/auth.h"
36 #include "util/util_ldb.h"
37 #include "dsdb/samdb/samdb.h"
38 #include "param/param.h"
40 static WERROR
DsCrackNameOneFilter(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
41 struct smb_krb5_context
*smb_krb5_context
,
42 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
43 struct ldb_dn
*name_dn
, const char *name
,
44 const char *domain_filter
, const char *result_filter
,
45 struct drsuapi_DsNameInfo1
*info1
);
46 static WERROR
DsCrackNameOneSyntactical(TALLOC_CTX
*mem_ctx
,
47 uint32_t format_offered
, uint32_t format_desired
,
48 struct ldb_dn
*name_dn
, const char *name
,
49 struct drsuapi_DsNameInfo1
*info1
);
51 static WERROR
dns_domain_from_principal(TALLOC_CTX
*mem_ctx
, struct smb_krb5_context
*smb_krb5_context
,
53 struct drsuapi_DsNameInfo1
*info1
)
56 krb5_principal principal
;
57 /* perhaps it's a principal with a realm, so return the right 'domain only' response */
59 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
, name
,
60 KRB5_PRINCIPAL_PARSE_MUST_REALM
, &principal
);
62 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
66 /* This isn't an allocation assignemnt, so it is free'ed with the krb5_free_principal */
67 realm
= krb5_princ_realm(smb_krb5_context
->krb5_context
, principal
);
69 info1
->dns_domain_name
= talloc_strdup(mem_ctx
, *realm
);
70 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
72 W_ERROR_HAVE_NO_MEMORY(info1
->dns_domain_name
);
74 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
78 static enum drsuapi_DsNameStatus
LDB_lookup_spn_alias(krb5_context context
, struct ldb_context
*ldb_ctx
,
80 const char *alias_from
,
85 struct ldb_result
*res
;
86 struct ldb_message_element
*spnmappings
;
88 struct ldb_dn
*service_dn
;
91 const char *directory_attrs
[] = {
96 tmp_ctx
= talloc_new(mem_ctx
);
98 return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
101 service_dn
= ldb_dn_new(tmp_ctx
, ldb_ctx
, "CN=Directory Service,CN=Windows NT,CN=Services");
102 if ( ! ldb_dn_add_base(service_dn
, samdb_config_dn(ldb_ctx
))) {
103 return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
105 service_dn_str
= ldb_dn_alloc_linearized(tmp_ctx
, service_dn
);
106 if ( ! service_dn_str
) {
107 return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
110 ret
= ldb_search(ldb_ctx
, tmp_ctx
, &res
, service_dn
, LDB_SCOPE_BASE
,
111 directory_attrs
, "(objectClass=nTDSService)");
113 if (ret
!= LDB_SUCCESS
&& ret
!= LDB_ERR_NO_SUCH_OBJECT
) {
114 DEBUG(1, ("ldb_search: dn: %s not found: %s", service_dn_str
, ldb_errstring(ldb_ctx
)));
115 return DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
116 } else if (ret
== LDB_ERR_NO_SUCH_OBJECT
) {
117 DEBUG(1, ("ldb_search: dn: %s not found", service_dn_str
));
118 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
119 } else if (res
->count
!= 1) {
121 DEBUG(1, ("ldb_search: dn: %s not found", service_dn_str
));
122 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
125 spnmappings
= ldb_msg_find_element(res
->msgs
[0], "sPNMappings");
126 if (!spnmappings
|| spnmappings
->num_values
== 0) {
127 DEBUG(1, ("ldb_search: dn: %s no sPNMappings attribute", service_dn_str
));
128 talloc_free(tmp_ctx
);
129 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
132 for (i
= 0; i
< spnmappings
->num_values
; i
++) {
133 char *mapping
, *p
, *str
;
134 mapping
= talloc_strdup(tmp_ctx
,
135 (const char *)spnmappings
->values
[i
].data
);
137 DEBUG(1, ("LDB_lookup_spn_alias: ldb_search: dn: %s did not have an sPNMapping\n", service_dn_str
));
138 talloc_free(tmp_ctx
);
139 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
142 /* C string manipulation sucks */
144 p
= strchr(mapping
, '=');
146 DEBUG(1, ("ldb_search: dn: %s sPNMapping malformed: %s\n",
147 service_dn_str
, mapping
));
148 talloc_free(tmp_ctx
);
149 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
160 if (strcasecmp(str
, alias_from
) == 0) {
162 talloc_steal(mem_ctx
, mapping
);
163 talloc_free(tmp_ctx
);
164 return DRSUAPI_DS_NAME_STATUS_OK
;
168 DEBUG(4, ("LDB_lookup_spn_alias: no alias for service %s applicable\n", alias_from
));
169 talloc_free(tmp_ctx
);
170 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
173 /* When cracking a ServicePrincipalName, many services may be served
174 * by the host/ servicePrincipalName. The incoming query is for cifs/
175 * but we translate it here, and search on host/. This is done after
176 * the cifs/ entry has been searched for, making this a fallback */
178 static WERROR
DsCrackNameSPNAlias(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
179 struct smb_krb5_context
*smb_krb5_context
,
180 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
181 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
185 krb5_principal principal
;
186 const char *service
, *dns_name
;
189 enum drsuapi_DsNameStatus namestatus
;
191 /* parse principal */
192 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
,
193 name
, KRB5_PRINCIPAL_PARSE_NO_REALM
, &principal
);
195 DEBUG(2, ("Could not parse principal: %s: %s",
196 name
, smb_get_krb5_error_message(smb_krb5_context
->krb5_context
,
201 /* grab cifs/, http/ etc */
203 /* This is checked for in callers, but be safe */
204 if (principal
->name
.name_string
.len
< 2) {
205 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
208 service
= principal
->name
.name_string
.val
[0];
209 dns_name
= principal
->name
.name_string
.val
[1];
212 namestatus
= LDB_lookup_spn_alias(smb_krb5_context
->krb5_context
,
214 service
, &new_service
);
216 if (namestatus
== DRSUAPI_DS_NAME_STATUS_NOT_FOUND
) {
217 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
218 info1
->dns_domain_name
= talloc_strdup(mem_ctx
, dns_name
);
219 if (!info1
->dns_domain_name
) {
220 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
224 } else if (namestatus
!= DRSUAPI_DS_NAME_STATUS_OK
) {
225 info1
->status
= namestatus
;
226 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
230 /* ooh, very nasty playing around in the Principal... */
231 free(principal
->name
.name_string
.val
[0]);
232 principal
->name
.name_string
.val
[0] = strdup(new_service
);
233 if (!principal
->name
.name_string
.val
[0]) {
234 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
238 /* reform principal */
239 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
240 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &new_princ
);
243 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
247 wret
= DsCrackNameOneName(sam_ctx
, mem_ctx
, format_flags
, format_offered
, format_desired
,
250 if (W_ERROR_IS_OK(wret
) && (info1
->status
== DRSUAPI_DS_NAME_STATUS_NOT_FOUND
)) {
251 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
252 info1
->dns_domain_name
= talloc_strdup(mem_ctx
, dns_name
);
253 if (!info1
->dns_domain_name
) {
257 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
261 /* Subcase of CrackNames, for the userPrincipalName */
263 static WERROR
DsCrackNameUPN(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
264 struct smb_krb5_context
*smb_krb5_context
,
265 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
266 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
270 const char *domain_filter
= NULL
;
271 const char *result_filter
= NULL
;
273 krb5_principal principal
;
275 char *unparsed_name_short
;
276 const char *domain_attrs
[] = { NULL
};
277 struct ldb_result
*domain_res
= NULL
;
279 /* Prevent recursion */
281 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
285 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
, name
,
286 KRB5_PRINCIPAL_PARSE_MUST_REALM
, &principal
);
288 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
292 realm
= krb5_princ_realm(smb_krb5_context
->krb5_context
, principal
);
294 ldb_ret
= ldb_search(sam_ctx
, mem_ctx
, &domain_res
,
295 samdb_partitions_dn(sam_ctx
, mem_ctx
),
298 "(&(&(|(&(dnsRoot=%s)(nETBIOSName=*))(nETBIOSName=%s))(objectclass=crossRef))(ncName=*))",
299 ldb_binary_encode_string(mem_ctx
, *realm
),
300 ldb_binary_encode_string(mem_ctx
, *realm
));
302 if (ldb_ret
!= LDB_SUCCESS
) {
303 DEBUG(2, ("DsCrackNameUPN domain ref search failed: %s", ldb_errstring(sam_ctx
)));
304 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
308 switch (domain_res
->count
) {
312 return dns_domain_from_principal(mem_ctx
, smb_krb5_context
,
315 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
319 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
320 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &unparsed_name_short
);
321 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
324 free(unparsed_name_short
);
328 /* This may need to be extended for more userPrincipalName variations */
329 result_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=user)(samAccountName=%s))",
330 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
));
332 domain_filter
= talloc_asprintf(mem_ctx
, "(distinguishedName=%s)", ldb_dn_get_linearized(domain_res
->msgs
[0]->dn
));
334 if (!result_filter
|| !domain_filter
) {
335 free(unparsed_name_short
);
338 status
= DsCrackNameOneFilter(sam_ctx
, mem_ctx
,
340 format_flags
, format_offered
, format_desired
,
341 NULL
, unparsed_name_short
, domain_filter
, result_filter
,
343 free(unparsed_name_short
);
348 /* Crack a single 'name', from format_offered into format_desired, returning the result in info1 */
350 WERROR
DsCrackNameOneName(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
351 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
352 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
355 const char *domain_filter
= NULL
;
356 const char *result_filter
= NULL
;
357 struct ldb_dn
*name_dn
= NULL
;
359 struct smb_krb5_context
*smb_krb5_context
;
360 ret
= smb_krb5_init_context(mem_ctx
,
361 ldb_get_event_context(sam_ctx
),
362 (struct loadparm_context
*)ldb_get_opaque(sam_ctx
, "loadparm"),
369 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
370 info1
->dns_domain_name
= NULL
;
371 info1
->result_name
= NULL
;
374 return WERR_INVALID_PARAM
;
377 /* TODO: - fill the correct names in all cases!
378 * - handle format_flags
381 /* here we need to set the domain_filter and/or the result_filter */
382 switch (format_offered
) {
383 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
384 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
386 char *str
, *s
, *account
;
388 if (strlen(name
) == 0) {
389 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
393 str
= talloc_strdup(mem_ctx
, name
);
394 W_ERROR_HAVE_NO_MEMORY(str
);
396 if (format_offered
== DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
) {
397 /* Look backwards for the \n, and replace it with / */
398 s
= strrchr(str
, '\n');
400 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
406 s
= strchr(str
, '/');
408 /* there must be at least one / */
409 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
416 domain_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=crossRef)(ncName=%s))",
417 ldb_dn_get_linearized(samdb_dns_domain_to_dn(sam_ctx
, mem_ctx
, str
)));
418 W_ERROR_HAVE_NO_MEMORY(domain_filter
);
420 /* There may not be anything after the domain component (search for the domain itself) */
423 account
= strrchr(s
, '/');
429 account
= ldb_binary_encode_string(mem_ctx
, account
);
430 W_ERROR_HAVE_NO_MEMORY(account
);
431 result_filter
= talloc_asprintf(mem_ctx
, "(name=%s)",
433 W_ERROR_HAVE_NO_MEMORY(result_filter
);
437 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
: {
440 const char *account
= NULL
;
442 domain
= talloc_strdup(mem_ctx
, name
);
443 W_ERROR_HAVE_NO_MEMORY(domain
);
445 p
= strchr(domain
, '\\');
447 /* invalid input format */
448 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
457 domain_filter
= talloc_asprintf(mem_ctx
,
458 "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))",
459 ldb_binary_encode_string(mem_ctx
, domain
));
460 W_ERROR_HAVE_NO_MEMORY(domain_filter
);
462 result_filter
= talloc_asprintf(mem_ctx
, "(sAMAccountName=%s)",
463 ldb_binary_encode_string(mem_ctx
, account
));
464 W_ERROR_HAVE_NO_MEMORY(result_filter
);
471 /* A LDAP DN as a string */
472 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
: {
473 domain_filter
= NULL
;
474 name_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, name
);
475 if (! ldb_dn_validate(name_dn
)) {
476 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
482 /* A GUID as a string */
483 case DRSUAPI_DS_NAME_FORMAT_GUID
: {
487 domain_filter
= NULL
;
489 nt_status
= GUID_from_string(name
, &guid
);
490 if (!NT_STATUS_IS_OK(nt_status
)) {
491 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
495 ldap_guid
= ldap_encode_ndr_GUID(mem_ctx
, &guid
);
499 result_filter
= talloc_asprintf(mem_ctx
, "(objectGUID=%s)",
501 W_ERROR_HAVE_NO_MEMORY(result_filter
);
504 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
: {
505 domain_filter
= NULL
;
507 result_filter
= talloc_asprintf(mem_ctx
, "(|(displayName=%s)(samAccountName=%s))",
508 ldb_binary_encode_string(mem_ctx
, name
),
509 ldb_binary_encode_string(mem_ctx
, name
));
510 W_ERROR_HAVE_NO_MEMORY(result_filter
);
514 /* A S-1234-5678 style string */
515 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY
: {
516 struct dom_sid
*sid
= dom_sid_parse_talloc(mem_ctx
, name
);
519 domain_filter
= NULL
;
521 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
524 ldap_sid
= ldap_encode_ndr_dom_sid(mem_ctx
,
529 result_filter
= talloc_asprintf(mem_ctx
, "(objectSid=%s)",
531 W_ERROR_HAVE_NO_MEMORY(result_filter
);
534 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
: {
535 krb5_principal principal
;
537 ret
= krb5_parse_name(smb_krb5_context
->krb5_context
, name
, &principal
);
539 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
543 domain_filter
= NULL
;
545 ret
= krb5_unparse_name(smb_krb5_context
->krb5_context
, principal
, &unparsed_name
);
547 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
551 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
552 result_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=user)(userPrincipalName=%s))",
553 ldb_binary_encode_string(mem_ctx
, unparsed_name
));
556 W_ERROR_HAVE_NO_MEMORY(result_filter
);
559 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
: {
560 krb5_principal principal
;
561 char *unparsed_name_short
;
563 ret
= krb5_parse_name(smb_krb5_context
->krb5_context
, name
, &principal
);
564 if (ret
== 0 && principal
->name
.name_string
.len
< 2) {
565 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
566 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
569 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
, name
,
570 KRB5_PRINCIPAL_PARSE_NO_REALM
, &principal
);
572 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
574 return dns_domain_from_principal(mem_ctx
, smb_krb5_context
,
578 domain_filter
= NULL
;
580 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
581 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &unparsed_name_short
);
583 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
587 service
= principal
->name
.name_string
.val
[0];
588 if ((principal
->name
.name_string
.len
== 2) && (strcasecmp(service
, "host") == 0)) {
589 /* the 'cn' attribute is just the leading part of the name */
591 computer_name
= talloc_strndup(mem_ctx
, principal
->name
.name_string
.val
[1],
592 strcspn(principal
->name
.name_string
.val
[1], "."));
593 if (computer_name
== NULL
) {
597 result_filter
= talloc_asprintf(mem_ctx
, "(|(&(servicePrincipalName=%s)(objectClass=user))(&(cn=%s)(objectClass=computer)))",
598 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
),
599 ldb_binary_encode_string(mem_ctx
, computer_name
));
601 result_filter
= talloc_asprintf(mem_ctx
, "(&(servicePrincipalName=%s)(objectClass=user))",
602 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
));
604 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
605 free(unparsed_name_short
);
606 W_ERROR_HAVE_NO_MEMORY(result_filter
);
611 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
617 if (format_flags
& DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY
) {
618 return DsCrackNameOneSyntactical(mem_ctx
, format_offered
, format_desired
,
619 name_dn
, name
, info1
);
622 return DsCrackNameOneFilter(sam_ctx
, mem_ctx
,
624 format_flags
, format_offered
, format_desired
,
626 domain_filter
, result_filter
,
630 /* Subcase of CrackNames. It is possible to translate a LDAP-style DN
631 * (FQDN_1779) into a canoical name without actually searching the
634 static WERROR
DsCrackNameOneSyntactical(TALLOC_CTX
*mem_ctx
,
635 uint32_t format_offered
, uint32_t format_desired
,
636 struct ldb_dn
*name_dn
, const char *name
,
637 struct drsuapi_DsNameInfo1
*info1
)
640 if (format_offered
!= DRSUAPI_DS_NAME_FORMAT_FQDN_1779
) {
641 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING
;
645 switch (format_desired
) {
646 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
647 cracked
= ldb_dn_canonical_string(mem_ctx
, name_dn
);
649 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
650 cracked
= ldb_dn_canonical_ex_string(mem_ctx
, name_dn
);
653 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING
;
656 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
657 info1
->result_name
= cracked
;
665 /* Given a filter for the domain, and one for the result, perform the
666 * ldb search. The format offered and desired flags change the
667 * behaviours, including what attributes to return.
669 * The smb_krb5_context is required because we use the krb5 libs for principal parsing
672 static WERROR
DsCrackNameOneFilter(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
673 struct smb_krb5_context
*smb_krb5_context
,
674 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
675 struct ldb_dn
*name_dn
, const char *name
,
676 const char *domain_filter
, const char *result_filter
,
677 struct drsuapi_DsNameInfo1
*info1
)
680 struct ldb_result
*domain_res
= NULL
;
681 const char * const *domain_attrs
;
682 const char * const *result_attrs
;
683 struct ldb_message
**result_res
= NULL
;
684 struct ldb_message
*result
= NULL
;
685 struct ldb_dn
*result_basedn
= NULL
;
688 struct ldb_dn
*partitions_basedn
= samdb_partitions_dn(sam_ctx
, mem_ctx
);
690 const char * const _domain_attrs_1779
[] = { "ncName", "dnsRoot", NULL
};
691 const char * const _result_attrs_null
[] = { NULL
};
693 const char * const _domain_attrs_canonical
[] = { "ncName", "dnsRoot", NULL
};
694 const char * const _result_attrs_canonical
[] = { "canonicalName", NULL
};
696 const char * const _domain_attrs_nt4
[] = { "ncName", "dnsRoot", "nETBIOSName", NULL
};
697 const char * const _result_attrs_nt4
[] = { "sAMAccountName", "objectSid", "objectClass", NULL
};
699 const char * const _domain_attrs_guid
[] = { "ncName", "dnsRoot", NULL
};
700 const char * const _result_attrs_guid
[] = { "objectGUID", NULL
};
702 const char * const _domain_attrs_display
[] = { "ncName", "dnsRoot", NULL
};
703 const char * const _result_attrs_display
[] = { "displayName", "samAccountName", NULL
};
705 const char * const _domain_attrs_none
[] = { "ncName", "dnsRoot" , NULL
};
706 const char * const _result_attrs_none
[] = { NULL
};
708 /* here we need to set the attrs lists for domain and result lookups */
709 switch (format_desired
) {
710 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
:
711 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
712 domain_attrs
= _domain_attrs_1779
;
713 result_attrs
= _result_attrs_null
;
715 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
716 domain_attrs
= _domain_attrs_canonical
;
717 result_attrs
= _result_attrs_canonical
;
719 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
:
720 domain_attrs
= _domain_attrs_nt4
;
721 result_attrs
= _result_attrs_nt4
;
723 case DRSUAPI_DS_NAME_FORMAT_GUID
:
724 domain_attrs
= _domain_attrs_guid
;
725 result_attrs
= _result_attrs_guid
;
727 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
:
728 domain_attrs
= _domain_attrs_display
;
729 result_attrs
= _result_attrs_display
;
732 domain_attrs
= _domain_attrs_none
;
733 result_attrs
= _result_attrs_none
;
738 /* if we have a domain_filter look it up and set the result_basedn and the dns_domain_name */
739 ldb_ret
= ldb_search(sam_ctx
, mem_ctx
, &domain_res
,
743 "%s", domain_filter
);
745 if (ldb_ret
!= LDB_SUCCESS
) {
746 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
747 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
751 switch (domain_res
->count
) {
755 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
758 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
762 info1
->dns_domain_name
= samdb_result_string(domain_res
->msgs
[0], "dnsRoot", NULL
);
763 W_ERROR_HAVE_NO_MEMORY(info1
->dns_domain_name
);
764 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
766 info1
->dns_domain_name
= NULL
;
767 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
772 struct ldb_result
*res
;
774 result_basedn
= samdb_result_dn(sam_ctx
, mem_ctx
, domain_res
->msgs
[0], "ncName", NULL
);
776 ret
= ldb_search(sam_ctx
, mem_ctx
, &res
,
777 result_basedn
, LDB_SCOPE_SUBTREE
,
778 result_attrs
, "%s", result_filter
);
779 if (ret
!= LDB_SUCCESS
) {
780 talloc_free(result_res
);
781 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
784 ldb_ret
= res
->count
;
785 result_res
= res
->msgs
;
787 /* search with the 'phantom root' flag */
788 struct ldb_request
*req
;
790 res
= talloc_zero(mem_ctx
, struct ldb_result
);
791 W_ERROR_HAVE_NO_MEMORY(res
);
793 ret
= ldb_build_search_req(&req
, sam_ctx
, mem_ctx
,
794 ldb_get_root_basedn(sam_ctx
),
800 ldb_search_default_callback
,
802 if (ret
== LDB_SUCCESS
) {
803 struct ldb_search_options_control
*search_options
;
804 search_options
= talloc(req
, struct ldb_search_options_control
);
805 W_ERROR_HAVE_NO_MEMORY(search_options
);
806 search_options
->search_options
= LDB_SEARCH_OPTION_PHANTOM_ROOT
;
808 ret
= ldb_request_add_control(req
, LDB_CONTROL_SEARCH_OPTIONS_OID
, false, search_options
);
810 if (ret
!= LDB_SUCCESS
) {
812 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
816 ret
= ldb_request(sam_ctx
, req
);
818 if (ret
== LDB_SUCCESS
) {
819 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
824 if (ret
!= LDB_SUCCESS
) {
825 DEBUG(2, ("DsCrackNameOneFilter phantom root search failed: %s",
826 ldb_errstring(sam_ctx
)));
827 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
830 ldb_ret
= res
->count
;
831 result_res
= res
->msgs
;
833 } else if (format_offered
== DRSUAPI_DS_NAME_FORMAT_FQDN_1779
) {
834 ldb_ret
= gendb_search_dn(sam_ctx
, mem_ctx
, name_dn
, &result_res
,
836 } else if (domain_res
) {
837 name_dn
= samdb_result_dn(sam_ctx
, mem_ctx
, domain_res
->msgs
[0], "ncName", NULL
);
838 ldb_ret
= gendb_search_dn(sam_ctx
, mem_ctx
, name_dn
, &result_res
,
842 DEBUG(0, ("LOGIC ERROR: DsCrackNameOneFilter domain ref search not availible: This can't happen..."));
843 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
849 result
= result_res
[0];
852 switch (format_offered
) {
853 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
:
854 return DsCrackNameSPNAlias(sam_ctx
, mem_ctx
,
856 format_flags
, format_offered
, format_desired
,
859 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
:
860 return DsCrackNameUPN(sam_ctx
, mem_ctx
, smb_krb5_context
,
861 format_flags
, format_offered
, format_desired
,
864 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
867 DEBUG(2, ("DsCrackNameOneFilter result search failed: %s", ldb_errstring(sam_ctx
)));
868 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
871 switch (format_offered
) {
872 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
873 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
875 const char *canonical_name
= NULL
; /* Not required, but we get warnings... */
876 /* We may need to manually filter further */
877 for (i
= 0; i
< ldb_ret
; i
++) {
878 switch (format_offered
) {
879 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
880 canonical_name
= ldb_dn_canonical_string(mem_ctx
, result_res
[i
]->dn
);
882 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
883 canonical_name
= ldb_dn_canonical_ex_string(mem_ctx
, result_res
[i
]->dn
);
886 if (strcasecmp_m(canonical_name
, name
) == 0) {
887 result
= result_res
[i
];
892 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
897 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
902 info1
->dns_domain_name
= ldb_dn_canonical_string(mem_ctx
, result
->dn
);
903 W_ERROR_HAVE_NO_MEMORY(info1
->dns_domain_name
);
904 p
= strchr(info1
->dns_domain_name
, '/');
909 /* here we can use result and domain_res[0] */
910 switch (format_desired
) {
911 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
: {
912 info1
->result_name
= ldb_dn_alloc_linearized(mem_ctx
, result
->dn
);
913 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
915 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
918 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
: {
919 info1
->result_name
= samdb_result_string(result
, "canonicalName", NULL
);
920 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
923 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
: {
924 /* Not in the virtual ldb attribute */
925 return DsCrackNameOneSyntactical(mem_ctx
,
926 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
927 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
,
928 result
->dn
, name
, info1
);
930 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
: {
932 const struct dom_sid
*sid
= samdb_result_dom_sid(mem_ctx
, result
, "objectSid");
933 const char *_acc
= "", *_dom
= "";
935 if (samdb_find_attribute(sam_ctx
, result
, "objectClass", "domain")) {
937 ldb_ret
= ldb_search(sam_ctx
, mem_ctx
, &domain_res
,
941 "(ncName=%s)", ldb_dn_get_linearized(result
->dn
));
943 if (ldb_ret
!= LDB_SUCCESS
) {
944 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
945 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
949 switch (domain_res
->count
) {
953 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
956 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
959 _dom
= samdb_result_string(domain_res
->msgs
[0], "nETBIOSName", NULL
);
960 W_ERROR_HAVE_NO_MEMORY(_dom
);
962 _acc
= samdb_result_string(result
, "sAMAccountName", NULL
);
964 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_MAPPING
;
967 if (dom_sid_in_domain(dom_sid_parse_talloc(mem_ctx
, SID_BUILTIN
), sid
)) {
970 const char *attrs
[] = { NULL
};
971 struct ldb_result
*domain_res2
;
972 struct dom_sid
*dom_sid
= dom_sid_dup(mem_ctx
, sid
);
976 dom_sid
->num_auths
--;
977 ldb_ret
= ldb_search(sam_ctx
, mem_ctx
, &domain_res
,
981 "(&(objectSid=%s)(objectClass=domain))",
982 ldap_encode_ndr_dom_sid(mem_ctx
, dom_sid
));
984 if (ldb_ret
!= LDB_SUCCESS
) {
985 DEBUG(2, ("DsCrackNameOneFilter domain search failed: %s", ldb_errstring(sam_ctx
)));
986 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
990 switch (domain_res
->count
) {
994 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
997 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1001 ldb_ret
= ldb_search(sam_ctx
, mem_ctx
, &domain_res2
,
1005 "(ncName=%s)", ldb_dn_get_linearized(domain_res
->msgs
[0]->dn
));
1007 if (ldb_ret
!= LDB_SUCCESS
) {
1008 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
1009 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
1013 switch (domain_res2
->count
) {
1017 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
1020 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1023 _dom
= samdb_result_string(domain_res2
->msgs
[0], "nETBIOSName", NULL
);
1024 W_ERROR_HAVE_NO_MEMORY(_dom
);
1028 info1
->result_name
= talloc_asprintf(mem_ctx
, "%s\\%s", _dom
, _acc
);
1029 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
1031 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1034 case DRSUAPI_DS_NAME_FORMAT_GUID
: {
1037 guid
= samdb_result_guid(result
, "objectGUID");
1039 info1
->result_name
= GUID_string2(mem_ctx
, &guid
);
1040 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
1042 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1045 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
: {
1046 info1
->result_name
= samdb_result_string(result
, "displayName", NULL
);
1047 if (!info1
->result_name
) {
1048 info1
->result_name
= samdb_result_string(result
, "sAMAccountName", NULL
);
1050 if (!info1
->result_name
) {
1051 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
1053 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1057 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
: {
1058 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1061 case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN
:
1062 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY
: {
1063 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
1067 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_MAPPING
;
1072 /* Given a user Principal Name (such as foo@bar.com),
1073 * return the user and domain DNs. This is used in the KDC to then
1074 * return the Keys and evaluate policy */
1076 NTSTATUS
crack_user_principal_name(struct ldb_context
*sam_ctx
,
1077 TALLOC_CTX
*mem_ctx
,
1078 const char *user_principal_name
,
1079 struct ldb_dn
**user_dn
,
1080 struct ldb_dn
**domain_dn
)
1083 struct drsuapi_DsNameInfo1 info1
;
1084 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1085 DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
,
1086 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1087 user_principal_name
,
1089 if (!W_ERROR_IS_OK(werr
)) {
1090 return werror_to_ntstatus(werr
);
1092 switch (info1
.status
) {
1093 case DRSUAPI_DS_NAME_STATUS_OK
:
1095 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1096 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1097 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1098 return NT_STATUS_NO_SUCH_USER
;
1099 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1101 return NT_STATUS_UNSUCCESSFUL
;
1104 *user_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1107 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1108 DRSUAPI_DS_NAME_FORMAT_CANONICAL
,
1109 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1110 talloc_asprintf(mem_ctx
, "%s/",
1111 info1
.dns_domain_name
),
1113 if (!W_ERROR_IS_OK(werr
)) {
1114 return werror_to_ntstatus(werr
);
1116 switch (info1
.status
) {
1117 case DRSUAPI_DS_NAME_STATUS_OK
:
1119 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1120 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1121 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1122 return NT_STATUS_NO_SUCH_USER
;
1123 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1125 return NT_STATUS_UNSUCCESSFUL
;
1128 *domain_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1131 return NT_STATUS_OK
;
1135 /* Given a Service Principal Name (such as host/foo.bar.com@BAR.COM),
1136 * return the user and domain DNs. This is used in the KDC to then
1137 * return the Keys and evaluate policy */
1139 NTSTATUS
crack_service_principal_name(struct ldb_context
*sam_ctx
,
1140 TALLOC_CTX
*mem_ctx
,
1141 const char *service_principal_name
,
1142 struct ldb_dn
**user_dn
,
1143 struct ldb_dn
**domain_dn
)
1146 struct drsuapi_DsNameInfo1 info1
;
1147 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1148 DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
,
1149 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1150 service_principal_name
,
1152 if (!W_ERROR_IS_OK(werr
)) {
1153 return werror_to_ntstatus(werr
);
1155 switch (info1
.status
) {
1156 case DRSUAPI_DS_NAME_STATUS_OK
:
1158 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1159 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1160 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1161 return NT_STATUS_NO_SUCH_USER
;
1162 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1164 return NT_STATUS_UNSUCCESSFUL
;
1167 *user_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1170 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1171 DRSUAPI_DS_NAME_FORMAT_CANONICAL
,
1172 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1173 talloc_asprintf(mem_ctx
, "%s/",
1174 info1
.dns_domain_name
),
1176 if (!W_ERROR_IS_OK(werr
)) {
1177 return werror_to_ntstatus(werr
);
1179 switch (info1
.status
) {
1180 case DRSUAPI_DS_NAME_STATUS_OK
:
1182 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1183 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1184 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1185 return NT_STATUS_NO_SUCH_USER
;
1186 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1188 return NT_STATUS_UNSUCCESSFUL
;
1191 *domain_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1194 return NT_STATUS_OK
;
1198 NTSTATUS
crack_name_to_nt4_name(TALLOC_CTX
*mem_ctx
,
1199 struct event_context
*ev_ctx
,
1200 struct loadparm_context
*lp_ctx
,
1201 uint32_t format_offered
,
1203 const char **nt4_domain
, const char **nt4_account
)
1206 struct drsuapi_DsNameInfo1 info1
;
1207 struct ldb_context
*ldb
;
1210 /* Handle anonymous bind */
1211 if (!name
|| !*name
) {
1214 return NT_STATUS_OK
;
1217 ldb
= samdb_connect(mem_ctx
, ev_ctx
, lp_ctx
, system_session(mem_ctx
, lp_ctx
));
1219 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
1222 werr
= DsCrackNameOneName(ldb
, mem_ctx
, 0,
1224 DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
,
1227 if (!W_ERROR_IS_OK(werr
)) {
1228 return werror_to_ntstatus(werr
);
1230 switch (info1
.status
) {
1231 case DRSUAPI_DS_NAME_STATUS_OK
:
1233 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1234 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1235 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1236 return NT_STATUS_NO_SUCH_USER
;
1237 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1239 return NT_STATUS_UNSUCCESSFUL
;
1242 *nt4_domain
= talloc_strdup(mem_ctx
, info1
.result_name
);
1244 p
= strchr(*nt4_domain
, '\\');
1246 return NT_STATUS_INVALID_PARAMETER
;
1251 *nt4_account
= talloc_strdup(mem_ctx
, &p
[1]);
1254 if (!*nt4_account
|| !*nt4_domain
) {
1255 return NT_STATUS_NO_MEMORY
;
1258 return NT_STATUS_OK
;
1261 NTSTATUS
crack_auto_name_to_nt4_name(TALLOC_CTX
*mem_ctx
,
1262 struct event_context
*ev_ctx
,
1263 struct loadparm_context
*lp_ctx
,
1265 const char **nt4_domain
,
1266 const char **nt4_account
)
1268 uint32_t format_offered
= DRSUAPI_DS_NAME_FORMAT_UKNOWN
;
1270 /* Handle anonymous bind */
1271 if (!name
|| !*name
) {
1274 return NT_STATUS_OK
;
1277 if (strchr_m(name
, '=')) {
1278 format_offered
= DRSUAPI_DS_NAME_FORMAT_FQDN_1779
;
1279 } else if (strchr_m(name
, '@')) {
1280 format_offered
= DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
;
1281 } else if (strchr_m(name
, '\\')) {
1282 format_offered
= DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
;
1283 } else if (strchr_m(name
, '/')) {
1284 format_offered
= DRSUAPI_DS_NAME_FORMAT_CANONICAL
;
1287 return crack_name_to_nt4_name(mem_ctx
, ev_ctx
, lp_ctx
, format_offered
, name
, nt4_domain
, nt4_account
);