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
, service_dn
, LDB_SCOPE_BASE
, "(objectClass=nTDSService)",
111 directory_attrs
, &res
);
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
;
124 talloc_steal(tmp_ctx
, res
);
126 spnmappings
= ldb_msg_find_element(res
->msgs
[0], "sPNMappings");
127 if (!spnmappings
|| spnmappings
->num_values
== 0) {
128 DEBUG(1, ("ldb_search: dn: %s no sPNMappings attribute", service_dn_str
));
129 talloc_free(tmp_ctx
);
130 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
133 for (i
= 0; i
< spnmappings
->num_values
; i
++) {
134 char *mapping
, *p
, *str
;
135 mapping
= talloc_strdup(tmp_ctx
,
136 (const char *)spnmappings
->values
[i
].data
);
138 DEBUG(1, ("LDB_lookup_spn_alias: ldb_search: dn: %s did not have an sPNMapping\n", service_dn_str
));
139 talloc_free(tmp_ctx
);
140 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
143 /* C string manipulation sucks */
145 p
= strchr(mapping
, '=');
147 DEBUG(1, ("ldb_search: dn: %s sPNMapping malformed: %s\n",
148 service_dn_str
, mapping
));
149 talloc_free(tmp_ctx
);
150 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
161 if (strcasecmp(str
, alias_from
) == 0) {
163 talloc_steal(mem_ctx
, mapping
);
164 talloc_free(tmp_ctx
);
165 return DRSUAPI_DS_NAME_STATUS_OK
;
169 DEBUG(4, ("LDB_lookup_spn_alias: no alias for service %s applicable\n", alias_from
));
170 talloc_free(tmp_ctx
);
171 return DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
174 /* When cracking a ServicePrincipalName, many services may be served
175 * by the host/ servicePrincipalName. The incoming query is for cifs/
176 * but we translate it here, and search on host/. This is done after
177 * the cifs/ entry has been searched for, making this a fallback */
179 static WERROR
DsCrackNameSPNAlias(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
180 struct smb_krb5_context
*smb_krb5_context
,
181 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
182 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
186 krb5_principal principal
;
187 const char *service
, *dns_name
;
190 enum drsuapi_DsNameStatus namestatus
;
192 /* parse principal */
193 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
,
194 name
, KRB5_PRINCIPAL_PARSE_NO_REALM
, &principal
);
196 DEBUG(2, ("Could not parse principal: %s: %s",
197 name
, smb_get_krb5_error_message(smb_krb5_context
->krb5_context
,
202 /* grab cifs/, http/ etc */
204 /* This is checked for in callers, but be safe */
205 if (principal
->name
.name_string
.len
< 2) {
206 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
209 service
= principal
->name
.name_string
.val
[0];
210 dns_name
= principal
->name
.name_string
.val
[1];
213 namestatus
= LDB_lookup_spn_alias(smb_krb5_context
->krb5_context
,
215 service
, &new_service
);
217 if (namestatus
== DRSUAPI_DS_NAME_STATUS_NOT_FOUND
) {
218 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
219 info1
->dns_domain_name
= talloc_strdup(mem_ctx
, dns_name
);
220 if (!info1
->dns_domain_name
) {
221 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
225 } else if (namestatus
!= DRSUAPI_DS_NAME_STATUS_OK
) {
226 info1
->status
= namestatus
;
227 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
231 /* ooh, very nasty playing around in the Principal... */
232 free(principal
->name
.name_string
.val
[0]);
233 principal
->name
.name_string
.val
[0] = strdup(new_service
);
234 if (!principal
->name
.name_string
.val
[0]) {
235 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
239 /* reform principal */
240 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
241 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &new_princ
);
244 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
248 wret
= DsCrackNameOneName(sam_ctx
, mem_ctx
, format_flags
, format_offered
, format_desired
,
251 if (W_ERROR_IS_OK(wret
) && (info1
->status
== DRSUAPI_DS_NAME_STATUS_NOT_FOUND
)) {
252 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
253 info1
->dns_domain_name
= talloc_strdup(mem_ctx
, dns_name
);
254 if (!info1
->dns_domain_name
) {
258 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
262 /* Subcase of CrackNames, for the userPrincipalName */
264 static WERROR
DsCrackNameUPN(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
265 struct smb_krb5_context
*smb_krb5_context
,
266 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
267 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
271 const char *domain_filter
= NULL
;
272 const char *result_filter
= NULL
;
274 krb5_principal principal
;
276 char *unparsed_name_short
;
277 const char *domain_attrs
[] = { NULL
};
278 struct ldb_result
*domain_res
= NULL
;
280 /* Prevent recursion */
282 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
286 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
, name
,
287 KRB5_PRINCIPAL_PARSE_MUST_REALM
, &principal
);
289 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
293 realm
= krb5_princ_realm(smb_krb5_context
->krb5_context
, principal
);
295 ldb_ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &domain_res
,
296 samdb_partitions_dn(sam_ctx
, mem_ctx
),
299 "(&(&(|(&(dnsRoot=%s)(nETBIOSName=*))(nETBIOSName=%s))(objectclass=crossRef))(ncName=*))",
300 ldb_binary_encode_string(mem_ctx
, *realm
),
301 ldb_binary_encode_string(mem_ctx
, *realm
));
303 if (ldb_ret
!= LDB_SUCCESS
) {
304 DEBUG(2, ("DsCrackNameUPN domain ref search failed: %s", ldb_errstring(sam_ctx
)));
305 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
309 switch (domain_res
->count
) {
313 return dns_domain_from_principal(mem_ctx
, smb_krb5_context
,
316 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
320 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
321 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &unparsed_name_short
);
322 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
325 free(unparsed_name_short
);
329 /* This may need to be extended for more userPrincipalName variations */
330 result_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=user)(samAccountName=%s))",
331 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
));
333 domain_filter
= talloc_asprintf(mem_ctx
, "(distinguishedName=%s)", ldb_dn_get_linearized(domain_res
->msgs
[0]->dn
));
335 if (!result_filter
|| !domain_filter
) {
336 free(unparsed_name_short
);
339 status
= DsCrackNameOneFilter(sam_ctx
, mem_ctx
,
341 format_flags
, format_offered
, format_desired
,
342 NULL
, unparsed_name_short
, domain_filter
, result_filter
,
344 free(unparsed_name_short
);
349 /* Crack a single 'name', from format_offered into format_desired, returning the result in info1 */
351 WERROR
DsCrackNameOneName(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
352 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
353 const char *name
, struct drsuapi_DsNameInfo1
*info1
)
356 const char *domain_filter
= NULL
;
357 const char *result_filter
= NULL
;
358 struct ldb_dn
*name_dn
= NULL
;
360 struct smb_krb5_context
*smb_krb5_context
;
361 ret
= smb_krb5_init_context(mem_ctx
,
362 ldb_get_event_context(sam_ctx
),
363 (struct loadparm_context
*)ldb_get_opaque(sam_ctx
, "loadparm"),
370 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
371 info1
->dns_domain_name
= NULL
;
372 info1
->result_name
= NULL
;
375 return WERR_INVALID_PARAM
;
378 /* TODO: - fill the correct names in all cases!
379 * - handle format_flags
382 /* here we need to set the domain_filter and/or the result_filter */
383 switch (format_offered
) {
384 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
385 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
387 char *str
, *s
, *account
;
389 if (strlen(name
) == 0) {
390 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
394 str
= talloc_strdup(mem_ctx
, name
);
395 W_ERROR_HAVE_NO_MEMORY(str
);
397 if (format_offered
== DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
) {
398 /* Look backwards for the \n, and replace it with / */
399 s
= strrchr(str
, '\n');
401 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
407 s
= strchr(str
, '/');
409 /* there must be at least one / */
410 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
417 domain_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=crossRef)(ncName=%s))",
418 ldb_dn_get_linearized(samdb_dns_domain_to_dn(sam_ctx
, mem_ctx
, str
)));
419 W_ERROR_HAVE_NO_MEMORY(domain_filter
);
421 /* There may not be anything after the domain component (search for the domain itself) */
424 account
= strrchr(s
, '/');
430 account
= ldb_binary_encode_string(mem_ctx
, account
);
431 W_ERROR_HAVE_NO_MEMORY(account
);
432 result_filter
= talloc_asprintf(mem_ctx
, "(name=%s)",
434 W_ERROR_HAVE_NO_MEMORY(result_filter
);
438 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
: {
441 const char *account
= NULL
;
443 domain
= talloc_strdup(mem_ctx
, name
);
444 W_ERROR_HAVE_NO_MEMORY(domain
);
446 p
= strchr(domain
, '\\');
448 /* invalid input format */
449 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
458 domain_filter
= talloc_asprintf(mem_ctx
,
459 "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))",
460 ldb_binary_encode_string(mem_ctx
, domain
));
461 W_ERROR_HAVE_NO_MEMORY(domain_filter
);
463 result_filter
= talloc_asprintf(mem_ctx
, "(sAMAccountName=%s)",
464 ldb_binary_encode_string(mem_ctx
, account
));
465 W_ERROR_HAVE_NO_MEMORY(result_filter
);
472 /* A LDAP DN as a string */
473 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
: {
474 domain_filter
= NULL
;
475 name_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, name
);
476 if (! ldb_dn_validate(name_dn
)) {
477 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
483 /* A GUID as a string */
484 case DRSUAPI_DS_NAME_FORMAT_GUID
: {
488 domain_filter
= NULL
;
490 nt_status
= GUID_from_string(name
, &guid
);
491 if (!NT_STATUS_IS_OK(nt_status
)) {
492 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
496 ldap_guid
= ldap_encode_ndr_GUID(mem_ctx
, &guid
);
500 result_filter
= talloc_asprintf(mem_ctx
, "(objectGUID=%s)",
502 W_ERROR_HAVE_NO_MEMORY(result_filter
);
505 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
: {
506 domain_filter
= NULL
;
508 result_filter
= talloc_asprintf(mem_ctx
, "(|(displayName=%s)(samAccountName=%s))",
509 ldb_binary_encode_string(mem_ctx
, name
),
510 ldb_binary_encode_string(mem_ctx
, name
));
511 W_ERROR_HAVE_NO_MEMORY(result_filter
);
515 /* A S-1234-5678 style string */
516 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY
: {
517 struct dom_sid
*sid
= dom_sid_parse_talloc(mem_ctx
, name
);
520 domain_filter
= NULL
;
522 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
525 ldap_sid
= ldap_encode_ndr_dom_sid(mem_ctx
,
530 result_filter
= talloc_asprintf(mem_ctx
, "(objectSid=%s)",
532 W_ERROR_HAVE_NO_MEMORY(result_filter
);
535 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
: {
536 krb5_principal principal
;
538 ret
= krb5_parse_name(smb_krb5_context
->krb5_context
, name
, &principal
);
540 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
544 domain_filter
= NULL
;
546 ret
= krb5_unparse_name(smb_krb5_context
->krb5_context
, principal
, &unparsed_name
);
548 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
552 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
553 result_filter
= talloc_asprintf(mem_ctx
, "(&(objectClass=user)(userPrincipalName=%s))",
554 ldb_binary_encode_string(mem_ctx
, unparsed_name
));
557 W_ERROR_HAVE_NO_MEMORY(result_filter
);
560 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
: {
561 krb5_principal principal
;
562 char *unparsed_name_short
;
564 ret
= krb5_parse_name(smb_krb5_context
->krb5_context
, name
, &principal
);
565 if (ret
== 0 && principal
->name
.name_string
.len
< 2) {
566 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
567 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
570 ret
= krb5_parse_name_flags(smb_krb5_context
->krb5_context
, name
,
571 KRB5_PRINCIPAL_PARSE_NO_REALM
, &principal
);
573 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
575 return dns_domain_from_principal(mem_ctx
, smb_krb5_context
,
579 domain_filter
= NULL
;
581 ret
= krb5_unparse_name_flags(smb_krb5_context
->krb5_context
, principal
,
582 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &unparsed_name_short
);
584 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
588 service
= principal
->name
.name_string
.val
[0];
589 if ((principal
->name
.name_string
.len
== 2) && (strcasecmp(service
, "host") == 0)) {
590 /* the 'cn' attribute is just the leading part of the name */
592 computer_name
= talloc_strndup(mem_ctx
, principal
->name
.name_string
.val
[1],
593 strcspn(principal
->name
.name_string
.val
[1], "."));
594 if (computer_name
== NULL
) {
598 result_filter
= talloc_asprintf(mem_ctx
, "(|(&(servicePrincipalName=%s)(objectClass=user))(&(cn=%s)(objectClass=computer)))",
599 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
),
600 ldb_binary_encode_string(mem_ctx
, computer_name
));
602 result_filter
= talloc_asprintf(mem_ctx
, "(&(servicePrincipalName=%s)(objectClass=user))",
603 ldb_binary_encode_string(mem_ctx
, unparsed_name_short
));
605 krb5_free_principal(smb_krb5_context
->krb5_context
, principal
);
606 free(unparsed_name_short
);
607 W_ERROR_HAVE_NO_MEMORY(result_filter
);
612 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
618 if (format_flags
& DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY
) {
619 return DsCrackNameOneSyntactical(mem_ctx
, format_offered
, format_desired
,
620 name_dn
, name
, info1
);
623 return DsCrackNameOneFilter(sam_ctx
, mem_ctx
,
625 format_flags
, format_offered
, format_desired
,
627 domain_filter
, result_filter
,
631 /* Subcase of CrackNames. It is possible to translate a LDAP-style DN
632 * (FQDN_1779) into a canoical name without actually searching the
635 static WERROR
DsCrackNameOneSyntactical(TALLOC_CTX
*mem_ctx
,
636 uint32_t format_offered
, uint32_t format_desired
,
637 struct ldb_dn
*name_dn
, const char *name
,
638 struct drsuapi_DsNameInfo1
*info1
)
641 if (format_offered
!= DRSUAPI_DS_NAME_FORMAT_FQDN_1779
) {
642 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING
;
646 switch (format_desired
) {
647 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
648 cracked
= ldb_dn_canonical_string(mem_ctx
, name_dn
);
650 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
651 cracked
= ldb_dn_canonical_ex_string(mem_ctx
, name_dn
);
654 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING
;
657 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
658 info1
->result_name
= cracked
;
666 /* Given a filter for the domain, and one for the result, perform the
667 * ldb search. The format offered and desired flags change the
668 * behaviours, including what attributes to return.
670 * The smb_krb5_context is required because we use the krb5 libs for principal parsing
673 static WERROR
DsCrackNameOneFilter(struct ldb_context
*sam_ctx
, TALLOC_CTX
*mem_ctx
,
674 struct smb_krb5_context
*smb_krb5_context
,
675 uint32_t format_flags
, uint32_t format_offered
, uint32_t format_desired
,
676 struct ldb_dn
*name_dn
, const char *name
,
677 const char *domain_filter
, const char *result_filter
,
678 struct drsuapi_DsNameInfo1
*info1
)
681 struct ldb_result
*domain_res
= NULL
;
682 const char * const *domain_attrs
;
683 const char * const *result_attrs
;
684 struct ldb_message
**result_res
= NULL
;
685 struct ldb_message
*result
= NULL
;
686 struct ldb_dn
*result_basedn
= NULL
;
689 struct ldb_dn
*partitions_basedn
= samdb_partitions_dn(sam_ctx
, mem_ctx
);
691 const char * const _domain_attrs_1779
[] = { "ncName", "dnsRoot", NULL
};
692 const char * const _result_attrs_null
[] = { NULL
};
694 const char * const _domain_attrs_canonical
[] = { "ncName", "dnsRoot", NULL
};
695 const char * const _result_attrs_canonical
[] = { "canonicalName", NULL
};
697 const char * const _domain_attrs_nt4
[] = { "ncName", "dnsRoot", "nETBIOSName", NULL
};
698 const char * const _result_attrs_nt4
[] = { "sAMAccountName", "objectSid", "objectClass", NULL
};
700 const char * const _domain_attrs_guid
[] = { "ncName", "dnsRoot", NULL
};
701 const char * const _result_attrs_guid
[] = { "objectGUID", NULL
};
703 const char * const _domain_attrs_display
[] = { "ncName", "dnsRoot", NULL
};
704 const char * const _result_attrs_display
[] = { "displayName", "samAccountName", NULL
};
706 const char * const _domain_attrs_none
[] = { "ncName", "dnsRoot" , NULL
};
707 const char * const _result_attrs_none
[] = { NULL
};
709 /* here we need to set the attrs lists for domain and result lookups */
710 switch (format_desired
) {
711 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
:
712 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
713 domain_attrs
= _domain_attrs_1779
;
714 result_attrs
= _result_attrs_null
;
716 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
717 domain_attrs
= _domain_attrs_canonical
;
718 result_attrs
= _result_attrs_canonical
;
720 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
:
721 domain_attrs
= _domain_attrs_nt4
;
722 result_attrs
= _result_attrs_nt4
;
724 case DRSUAPI_DS_NAME_FORMAT_GUID
:
725 domain_attrs
= _domain_attrs_guid
;
726 result_attrs
= _result_attrs_guid
;
728 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
:
729 domain_attrs
= _domain_attrs_display
;
730 result_attrs
= _result_attrs_display
;
733 domain_attrs
= _domain_attrs_none
;
734 result_attrs
= _result_attrs_none
;
739 /* if we have a domain_filter look it up and set the result_basedn and the dns_domain_name */
740 ldb_ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &domain_res
,
744 "%s", domain_filter
);
746 if (ldb_ret
!= LDB_SUCCESS
) {
747 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
748 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
752 switch (domain_res
->count
) {
756 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
759 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
763 info1
->dns_domain_name
= samdb_result_string(domain_res
->msgs
[0], "dnsRoot", NULL
);
764 W_ERROR_HAVE_NO_MEMORY(info1
->dns_domain_name
);
765 info1
->status
= DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
;
767 info1
->dns_domain_name
= NULL
;
768 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
773 struct ldb_result
*res
;
775 result_basedn
= samdb_result_dn(sam_ctx
, mem_ctx
, domain_res
->msgs
[0], "ncName", NULL
);
777 ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &res
,
778 result_basedn
, LDB_SCOPE_SUBTREE
,
779 result_attrs
, "%s", result_filter
);
780 if (ret
!= LDB_SUCCESS
) {
781 talloc_free(result_res
);
782 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
785 ldb_ret
= res
->count
;
786 result_res
= res
->msgs
;
788 /* search with the 'phantom root' flag */
789 struct ldb_request
*req
;
791 res
= talloc_zero(mem_ctx
, struct ldb_result
);
792 W_ERROR_HAVE_NO_MEMORY(res
);
794 ret
= ldb_build_search_req(&req
, sam_ctx
, mem_ctx
,
795 ldb_get_root_basedn(sam_ctx
),
801 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 ldb_set_timeout(sam_ctx
, req
, 0); /* use default timeout */
818 ret
= ldb_request(sam_ctx
, req
);
820 if (ret
== LDB_SUCCESS
) {
821 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
826 if (ret
!= LDB_SUCCESS
) {
827 DEBUG(2, ("DsCrackNameOneFilter phantom root search failed: %s",
828 ldb_errstring(sam_ctx
)));
829 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
832 ldb_ret
= res
->count
;
833 result_res
= res
->msgs
;
835 } else if (format_offered
== DRSUAPI_DS_NAME_FORMAT_FQDN_1779
) {
836 ldb_ret
= gendb_search_dn(sam_ctx
, mem_ctx
, name_dn
, &result_res
,
838 } else if (domain_res
) {
839 name_dn
= samdb_result_dn(sam_ctx
, mem_ctx
, domain_res
->msgs
[0], "ncName", NULL
);
840 ldb_ret
= gendb_search_dn(sam_ctx
, mem_ctx
, name_dn
, &result_res
,
844 DEBUG(0, ("LOGIC ERROR: DsCrackNameOneFilter domain ref search not availible: This can't happen..."));
845 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
851 result
= result_res
[0];
854 switch (format_offered
) {
855 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
:
856 return DsCrackNameSPNAlias(sam_ctx
, mem_ctx
,
858 format_flags
, format_offered
, format_desired
,
861 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
:
862 return DsCrackNameUPN(sam_ctx
, mem_ctx
, smb_krb5_context
,
863 format_flags
, format_offered
, format_desired
,
866 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
869 DEBUG(2, ("DsCrackNameOneFilter result search failed: %s", ldb_errstring(sam_ctx
)));
870 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
873 switch (format_offered
) {
874 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
875 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
877 const char *canonical_name
= NULL
; /* Not required, but we get warnings... */
878 /* We may need to manually filter further */
879 for (i
= 0; i
< ldb_ret
; i
++) {
880 switch (format_offered
) {
881 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
:
882 canonical_name
= ldb_dn_canonical_string(mem_ctx
, result_res
[i
]->dn
);
884 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
:
885 canonical_name
= ldb_dn_canonical_ex_string(mem_ctx
, result_res
[i
]->dn
);
888 if (strcasecmp_m(canonical_name
, name
) == 0) {
889 result
= result_res
[i
];
894 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
899 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
904 info1
->dns_domain_name
= ldb_dn_canonical_string(mem_ctx
, result
->dn
);
905 W_ERROR_HAVE_NO_MEMORY(info1
->dns_domain_name
);
906 p
= strchr(info1
->dns_domain_name
, '/');
911 /* here we can use result and domain_res[0] */
912 switch (format_desired
) {
913 case DRSUAPI_DS_NAME_FORMAT_FQDN_1779
: {
914 info1
->result_name
= ldb_dn_alloc_linearized(mem_ctx
, result
->dn
);
915 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
917 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
920 case DRSUAPI_DS_NAME_FORMAT_CANONICAL
: {
921 info1
->result_name
= samdb_result_string(result
, "canonicalName", NULL
);
922 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
925 case DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
: {
926 /* Not in the virtual ldb attribute */
927 return DsCrackNameOneSyntactical(mem_ctx
,
928 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
929 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX
,
930 result
->dn
, name
, info1
);
932 case DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
: {
934 const struct dom_sid
*sid
= samdb_result_dom_sid(mem_ctx
, result
, "objectSid");
935 const char *_acc
= "", *_dom
= "";
937 if (samdb_find_attribute(sam_ctx
, result
, "objectClass", "domain")) {
939 ldb_ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &domain_res
,
943 "(ncName=%s)", ldb_dn_get_linearized(result
->dn
));
945 if (ldb_ret
!= LDB_SUCCESS
) {
946 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
947 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
951 switch (domain_res
->count
) {
955 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
958 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
961 _dom
= samdb_result_string(domain_res
->msgs
[0], "nETBIOSName", NULL
);
962 W_ERROR_HAVE_NO_MEMORY(_dom
);
964 _acc
= samdb_result_string(result
, "sAMAccountName", NULL
);
966 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_MAPPING
;
969 if (dom_sid_in_domain(dom_sid_parse_talloc(mem_ctx
, SID_BUILTIN
), sid
)) {
972 const char *attrs
[] = { NULL
};
973 struct ldb_result
*domain_res2
;
974 struct dom_sid
*dom_sid
= dom_sid_dup(mem_ctx
, sid
);
978 dom_sid
->num_auths
--;
979 ldb_ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &domain_res
,
983 "(&(objectSid=%s)(objectClass=domain))",
984 ldap_encode_ndr_dom_sid(mem_ctx
, dom_sid
));
986 if (ldb_ret
!= LDB_SUCCESS
) {
987 DEBUG(2, ("DsCrackNameOneFilter domain search failed: %s", ldb_errstring(sam_ctx
)));
988 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
992 switch (domain_res
->count
) {
996 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
999 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1003 ldb_ret
= ldb_search_exp_fmt(sam_ctx
, mem_ctx
, &domain_res2
,
1007 "(ncName=%s)", ldb_dn_get_linearized(domain_res
->msgs
[0]->dn
));
1009 if (ldb_ret
!= LDB_SUCCESS
) {
1010 DEBUG(2, ("DsCrackNameOneFilter domain ref search failed: %s", ldb_errstring(sam_ctx
)));
1011 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
1015 switch (domain_res2
->count
) {
1019 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
1022 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1025 _dom
= samdb_result_string(domain_res2
->msgs
[0], "nETBIOSName", NULL
);
1026 W_ERROR_HAVE_NO_MEMORY(_dom
);
1030 info1
->result_name
= talloc_asprintf(mem_ctx
, "%s\\%s", _dom
, _acc
);
1031 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
1033 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1036 case DRSUAPI_DS_NAME_FORMAT_GUID
: {
1039 guid
= samdb_result_guid(result
, "objectGUID");
1041 info1
->result_name
= GUID_string2(mem_ctx
, &guid
);
1042 W_ERROR_HAVE_NO_MEMORY(info1
->result_name
);
1044 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1047 case DRSUAPI_DS_NAME_FORMAT_DISPLAY
: {
1048 info1
->result_name
= samdb_result_string(result
, "displayName", NULL
);
1049 if (!info1
->result_name
) {
1050 info1
->result_name
= samdb_result_string(result
, "sAMAccountName", NULL
);
1052 if (!info1
->result_name
) {
1053 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_FOUND
;
1055 info1
->status
= DRSUAPI_DS_NAME_STATUS_OK
;
1059 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
: {
1060 info1
->status
= DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
;
1063 case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN
:
1064 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY
: {
1065 info1
->status
= DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
;
1069 info1
->status
= DRSUAPI_DS_NAME_STATUS_NO_MAPPING
;
1074 /* Given a user Principal Name (such as foo@bar.com),
1075 * return the user and domain DNs. This is used in the KDC to then
1076 * return the Keys and evaluate policy */
1078 NTSTATUS
crack_user_principal_name(struct ldb_context
*sam_ctx
,
1079 TALLOC_CTX
*mem_ctx
,
1080 const char *user_principal_name
,
1081 struct ldb_dn
**user_dn
,
1082 struct ldb_dn
**domain_dn
)
1085 struct drsuapi_DsNameInfo1 info1
;
1086 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1087 DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
,
1088 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1089 user_principal_name
,
1091 if (!W_ERROR_IS_OK(werr
)) {
1092 return werror_to_ntstatus(werr
);
1094 switch (info1
.status
) {
1095 case DRSUAPI_DS_NAME_STATUS_OK
:
1097 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1098 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1099 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1100 return NT_STATUS_NO_SUCH_USER
;
1101 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1103 return NT_STATUS_UNSUCCESSFUL
;
1106 *user_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1109 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1110 DRSUAPI_DS_NAME_FORMAT_CANONICAL
,
1111 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1112 talloc_asprintf(mem_ctx
, "%s/",
1113 info1
.dns_domain_name
),
1115 if (!W_ERROR_IS_OK(werr
)) {
1116 return werror_to_ntstatus(werr
);
1118 switch (info1
.status
) {
1119 case DRSUAPI_DS_NAME_STATUS_OK
:
1121 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1122 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1123 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1124 return NT_STATUS_NO_SUCH_USER
;
1125 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1127 return NT_STATUS_UNSUCCESSFUL
;
1130 *domain_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1133 return NT_STATUS_OK
;
1137 /* Given a Service Principal Name (such as host/foo.bar.com@BAR.COM),
1138 * return the user and domain DNs. This is used in the KDC to then
1139 * return the Keys and evaluate policy */
1141 NTSTATUS
crack_service_principal_name(struct ldb_context
*sam_ctx
,
1142 TALLOC_CTX
*mem_ctx
,
1143 const char *service_principal_name
,
1144 struct ldb_dn
**user_dn
,
1145 struct ldb_dn
**domain_dn
)
1148 struct drsuapi_DsNameInfo1 info1
;
1149 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1150 DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL
,
1151 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1152 service_principal_name
,
1154 if (!W_ERROR_IS_OK(werr
)) {
1155 return werror_to_ntstatus(werr
);
1157 switch (info1
.status
) {
1158 case DRSUAPI_DS_NAME_STATUS_OK
:
1160 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1161 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1162 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1163 return NT_STATUS_NO_SUCH_USER
;
1164 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1166 return NT_STATUS_UNSUCCESSFUL
;
1169 *user_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1172 werr
= DsCrackNameOneName(sam_ctx
, mem_ctx
, 0,
1173 DRSUAPI_DS_NAME_FORMAT_CANONICAL
,
1174 DRSUAPI_DS_NAME_FORMAT_FQDN_1779
,
1175 talloc_asprintf(mem_ctx
, "%s/",
1176 info1
.dns_domain_name
),
1178 if (!W_ERROR_IS_OK(werr
)) {
1179 return werror_to_ntstatus(werr
);
1181 switch (info1
.status
) {
1182 case DRSUAPI_DS_NAME_STATUS_OK
:
1184 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1185 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1186 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1187 return NT_STATUS_NO_SUCH_USER
;
1188 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1190 return NT_STATUS_UNSUCCESSFUL
;
1193 *domain_dn
= ldb_dn_new(mem_ctx
, sam_ctx
, info1
.result_name
);
1196 return NT_STATUS_OK
;
1200 NTSTATUS
crack_name_to_nt4_name(TALLOC_CTX
*mem_ctx
,
1201 struct event_context
*ev_ctx
,
1202 struct loadparm_context
*lp_ctx
,
1203 uint32_t format_offered
,
1205 const char **nt4_domain
, const char **nt4_account
)
1208 struct drsuapi_DsNameInfo1 info1
;
1209 struct ldb_context
*ldb
;
1212 /* Handle anonymous bind */
1213 if (!name
|| !*name
) {
1216 return NT_STATUS_OK
;
1219 ldb
= samdb_connect(mem_ctx
, ev_ctx
, lp_ctx
, system_session(mem_ctx
, lp_ctx
));
1221 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
1224 werr
= DsCrackNameOneName(ldb
, mem_ctx
, 0,
1226 DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
,
1229 if (!W_ERROR_IS_OK(werr
)) {
1230 return werror_to_ntstatus(werr
);
1232 switch (info1
.status
) {
1233 case DRSUAPI_DS_NAME_STATUS_OK
:
1235 case DRSUAPI_DS_NAME_STATUS_NOT_FOUND
:
1236 case DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY
:
1237 case DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE
:
1238 return NT_STATUS_NO_SUCH_USER
;
1239 case DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR
:
1241 return NT_STATUS_UNSUCCESSFUL
;
1244 *nt4_domain
= talloc_strdup(mem_ctx
, info1
.result_name
);
1246 p
= strchr(*nt4_domain
, '\\');
1248 return NT_STATUS_INVALID_PARAMETER
;
1253 *nt4_account
= talloc_strdup(mem_ctx
, &p
[1]);
1256 if (!*nt4_account
|| !*nt4_domain
) {
1257 return NT_STATUS_NO_MEMORY
;
1260 return NT_STATUS_OK
;
1263 NTSTATUS
crack_auto_name_to_nt4_name(TALLOC_CTX
*mem_ctx
,
1264 struct event_context
*ev_ctx
,
1265 struct loadparm_context
*lp_ctx
,
1267 const char **nt4_domain
,
1268 const char **nt4_account
)
1270 uint32_t format_offered
= DRSUAPI_DS_NAME_FORMAT_UKNOWN
;
1272 /* Handle anonymous bind */
1273 if (!name
|| !*name
) {
1276 return NT_STATUS_OK
;
1279 if (strchr_m(name
, '=')) {
1280 format_offered
= DRSUAPI_DS_NAME_FORMAT_FQDN_1779
;
1281 } else if (strchr_m(name
, '@')) {
1282 format_offered
= DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL
;
1283 } else if (strchr_m(name
, '\\')) {
1284 format_offered
= DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
;
1285 } else if (strchr_m(name
, '/')) {
1286 format_offered
= DRSUAPI_DS_NAME_FORMAT_CANONICAL
;
1289 return crack_name_to_nt4_name(mem_ctx
, ev_ctx
, lp_ctx
, format_offered
, name
, nt4_domain
, nt4_account
);