2 Unix SMB/CIFS implementation.
3 IPA helper functions for SAMBA
4 Copyright (C) Sumit Bose <sbose@redhat.com> 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "libcli/security/dom_sid.h"
24 #include "../librpc/ndr/libndr.h"
25 #include "librpc/gen_ndr/samr.h"
30 #define IPA_KEYTAB_SET_OID "2.16.840.1.113730.3.8.3.1"
31 #define IPA_MAGIC_ID_STR "999"
33 #define LDAP_TRUST_CONTAINER "ou=system"
34 #define LDAP_ATTRIBUTE_CN "cn"
35 #define LDAP_ATTRIBUTE_TRUST_TYPE "sambaTrustType"
36 #define LDAP_ATTRIBUTE_TRUST_ATTRIBUTES "sambaTrustAttributes"
37 #define LDAP_ATTRIBUTE_TRUST_DIRECTION "sambaTrustDirection"
38 #define LDAP_ATTRIBUTE_TRUST_POSIX_OFFSET "sambaTrustPosixOffset"
39 #define LDAP_ATTRIBUTE_SUPPORTED_ENC_TYPE "sambaSupportedEncryptionTypes"
40 #define LDAP_ATTRIBUTE_TRUST_PARTNER "sambaTrustPartner"
41 #define LDAP_ATTRIBUTE_FLAT_NAME "sambaFlatName"
42 #define LDAP_ATTRIBUTE_TRUST_AUTH_OUTGOING "sambaTrustAuthOutgoing"
43 #define LDAP_ATTRIBUTE_TRUST_AUTH_INCOMING "sambaTrustAuthIncoming"
44 #define LDAP_ATTRIBUTE_SECURITY_IDENTIFIER "sambaSecurityIdentifier"
45 #define LDAP_ATTRIBUTE_TRUST_FOREST_TRUST_INFO "sambaTrustForestTrustInfo"
46 #define LDAP_ATTRIBUTE_OBJECTCLASS "objectClass"
48 #define LDAP_OBJ_KRB_PRINCIPAL "krbPrincipal"
49 #define LDAP_OBJ_KRB_PRINCIPAL_AUX "krbPrincipalAux"
50 #define LDAP_ATTRIBUTE_KRB_PRINCIPAL "krbPrincipalName"
52 #define LDAP_OBJ_IPAOBJECT "ipaObject"
53 #define LDAP_OBJ_IPAHOST "ipaHost"
54 #define LDAP_OBJ_POSIXACCOUNT "posixAccount"
56 #define LDAP_OBJ_GROUPOFNAMES "groupOfNames"
57 #define LDAP_OBJ_NESTEDGROUP "nestedGroup"
58 #define LDAP_OBJ_IPAUSERGROUP "ipaUserGroup"
59 #define LDAP_OBJ_POSIXGROUP "posixGroup"
61 #define HAS_KRB_PRINCIPAL (1<<0)
62 #define HAS_KRB_PRINCIPAL_AUX (1<<1)
63 #define HAS_IPAOBJECT (1<<2)
64 #define HAS_IPAHOST (1<<3)
65 #define HAS_POSIXACCOUNT (1<<4)
66 #define HAS_GROUPOFNAMES (1<<5)
67 #define HAS_NESTEDGROUP (1<<6)
68 #define HAS_IPAUSERGROUP (1<<7)
69 #define HAS_POSIXGROUP (1<<8)
71 struct ipasam_privates
{
73 NTSTATUS (*ldapsam_add_sam_account
)(struct pdb_methods
*,
74 struct samu
*sampass
);
75 NTSTATUS (*ldapsam_update_sam_account
)(struct pdb_methods
*,
76 struct samu
*sampass
);
77 NTSTATUS (*ldapsam_create_user
)(struct pdb_methods
*my_methods
,
78 TALLOC_CTX
*tmp_ctx
, const char *name
,
79 uint32_t acb_info
, uint32_t *rid
);
80 NTSTATUS (*ldapsam_create_dom_group
)(struct pdb_methods
*my_methods
,
86 static bool ipasam_get_trusteddom_pw(struct pdb_methods
*methods
,
90 time_t *pass_last_set_time
)
95 static bool ipasam_set_trusteddom_pw(struct pdb_methods
*methods
,
98 const struct dom_sid
*sid
)
103 static bool ipasam_del_trusteddom_pw(struct pdb_methods
*methods
,
109 static char *get_account_dn(const char *name
)
114 escape_name
= escape_rdn_val_string_alloc(name
);
119 if (name
[strlen(name
)-1] == '$') {
120 dn
= talloc_asprintf(talloc_tos(), "uid=%s,%s", escape_name
,
121 lp_ldap_machine_suffix());
123 dn
= talloc_asprintf(talloc_tos(), "uid=%s,%s", escape_name
,
124 lp_ldap_user_suffix());
127 SAFE_FREE(escape_name
);
132 static char *trusted_domain_dn(struct ldapsam_privates
*ldap_state
,
135 return talloc_asprintf(talloc_tos(), "%s=%s,%s,%s",
136 LDAP_ATTRIBUTE_CN
, domain
,
137 LDAP_TRUST_CONTAINER
, ldap_state
->domain_dn
);
140 static char *trusted_domain_base_dn(struct ldapsam_privates
*ldap_state
)
142 return talloc_asprintf(talloc_tos(), "%s,%s",
143 LDAP_TRUST_CONTAINER
, ldap_state
->domain_dn
);
146 static bool get_trusted_domain_int(struct ldapsam_privates
*ldap_state
,
148 const char *filter
, LDAPMessage
**entry
)
151 char *base_dn
= NULL
;
152 LDAPMessage
*result
= NULL
;
155 base_dn
= trusted_domain_base_dn(ldap_state
);
156 if (base_dn
== NULL
) {
160 rc
= smbldap_search(ldap_state
->smbldap_state
, base_dn
,
161 LDAP_SCOPE_SUBTREE
, filter
, NULL
, 0, &result
);
162 TALLOC_FREE(base_dn
);
164 if (result
!= NULL
) {
165 talloc_autofree_ldapmsg(mem_ctx
, result
);
168 if (rc
== LDAP_NO_SUCH_OBJECT
) {
173 if (rc
!= LDAP_SUCCESS
) {
177 num_result
= ldap_count_entries(priv2ld(ldap_state
), result
);
179 if (num_result
> 1) {
180 DEBUG(1, ("get_trusted_domain_int: more than one "
181 "%s object with filter '%s'?!\n",
182 LDAP_OBJ_TRUSTED_DOMAIN
, filter
));
186 if (num_result
== 0) {
187 DEBUG(1, ("get_trusted_domain_int: no "
188 "%s object with filter '%s'.\n",
189 LDAP_OBJ_TRUSTED_DOMAIN
, filter
));
192 *entry
= ldap_first_entry(priv2ld(ldap_state
), result
);
198 static bool get_trusted_domain_by_name_int(struct ldapsam_privates
*ldap_state
,
205 filter
= talloc_asprintf(talloc_tos(),
206 "(&(objectClass=%s)(|(%s=%s)(%s=%s)(cn=%s)))",
207 LDAP_OBJ_TRUSTED_DOMAIN
,
208 LDAP_ATTRIBUTE_FLAT_NAME
, domain
,
209 LDAP_ATTRIBUTE_TRUST_PARTNER
, domain
, domain
);
210 if (filter
== NULL
) {
214 return get_trusted_domain_int(ldap_state
, mem_ctx
, filter
, entry
);
217 static bool get_trusted_domain_by_sid_int(struct ldapsam_privates
*ldap_state
,
219 const char *sid
, LDAPMessage
**entry
)
223 filter
= talloc_asprintf(talloc_tos(), "(&(objectClass=%s)(%s=%s))",
224 LDAP_OBJ_TRUSTED_DOMAIN
,
225 LDAP_ATTRIBUTE_SECURITY_IDENTIFIER
, sid
);
226 if (filter
== NULL
) {
230 return get_trusted_domain_int(ldap_state
, mem_ctx
, filter
, entry
);
233 static bool get_uint32_t_from_ldap_msg(struct ldapsam_privates
*ldap_state
,
242 dummy
= smbldap_talloc_single_attribute(priv2ld(ldap_state
), entry
,
245 DEBUG(9, ("Attribute %s not present.\n", attr
));
250 l
= strtoul(dummy
, &endptr
, 10);
253 if (l
< 0 || l
> UINT32_MAX
|| *endptr
!= '\0') {
262 static void get_data_blob_from_ldap_msg(TALLOC_CTX
*mem_ctx
,
263 struct ldapsam_privates
*ldap_state
,
264 LDAPMessage
*entry
, const char *attr
,
270 dummy
= smbldap_talloc_single_attribute(priv2ld(ldap_state
), entry
, attr
,
273 DEBUG(9, ("Attribute %s not present.\n", attr
));
276 blob
= base64_decode_data_blob(dummy
);
277 if (blob
.length
== 0) {
280 _blob
->length
= blob
.length
;
281 _blob
->data
= talloc_steal(mem_ctx
, blob
.data
);
287 static bool fill_pdb_trusted_domain(TALLOC_CTX
*mem_ctx
,
288 struct ldapsam_privates
*ldap_state
,
290 struct pdb_trusted_domain
**_td
)
294 struct pdb_trusted_domain
*td
;
300 td
= talloc_zero(mem_ctx
, struct pdb_trusted_domain
);
305 /* All attributes are MAY */
307 dummy
= smbldap_talloc_single_attribute(priv2ld(ldap_state
), entry
,
308 LDAP_ATTRIBUTE_SECURITY_IDENTIFIER
,
311 DEBUG(9, ("Attribute %s not present.\n",
312 LDAP_ATTRIBUTE_SECURITY_IDENTIFIER
));
313 ZERO_STRUCT(td
->security_identifier
);
315 res
= string_to_sid(&td
->security_identifier
, dummy
);
322 get_data_blob_from_ldap_msg(td
, ldap_state
, entry
,
323 LDAP_ATTRIBUTE_TRUST_AUTH_INCOMING
,
324 &td
->trust_auth_incoming
);
326 get_data_blob_from_ldap_msg(td
, ldap_state
, entry
,
327 LDAP_ATTRIBUTE_TRUST_AUTH_OUTGOING
,
328 &td
->trust_auth_outgoing
);
330 td
->netbios_name
= smbldap_talloc_single_attribute(priv2ld(ldap_state
),
332 LDAP_ATTRIBUTE_FLAT_NAME
,
334 if (td
->netbios_name
== NULL
) {
335 DEBUG(9, ("Attribute %s not present.\n",
336 LDAP_ATTRIBUTE_FLAT_NAME
));
339 td
->domain_name
= smbldap_talloc_single_attribute(priv2ld(ldap_state
),
341 LDAP_ATTRIBUTE_TRUST_PARTNER
,
343 if (td
->domain_name
== NULL
) {
344 DEBUG(9, ("Attribute %s not present.\n",
345 LDAP_ATTRIBUTE_TRUST_PARTNER
));
348 res
= get_uint32_t_from_ldap_msg(ldap_state
, entry
,
349 LDAP_ATTRIBUTE_TRUST_DIRECTION
,
350 &td
->trust_direction
);
355 res
= get_uint32_t_from_ldap_msg(ldap_state
, entry
,
356 LDAP_ATTRIBUTE_TRUST_ATTRIBUTES
,
357 &td
->trust_attributes
);
362 res
= get_uint32_t_from_ldap_msg(ldap_state
, entry
,
363 LDAP_ATTRIBUTE_TRUST_TYPE
,
369 td
->trust_posix_offset
= talloc(td
, uint32_t);
370 if (td
->trust_posix_offset
== NULL
) {
373 res
= get_uint32_t_from_ldap_msg(ldap_state
, entry
,
374 LDAP_ATTRIBUTE_TRUST_POSIX_OFFSET
,
375 td
->trust_posix_offset
);
380 td
->supported_enc_type
= talloc(td
, uint32_t);
381 if (td
->supported_enc_type
== NULL
) {
384 res
= get_uint32_t_from_ldap_msg(ldap_state
, entry
,
385 LDAP_ATTRIBUTE_SUPPORTED_ENC_TYPE
,
386 td
->supported_enc_type
);
392 get_data_blob_from_ldap_msg(td
, ldap_state
, entry
,
393 LDAP_ATTRIBUTE_TRUST_FOREST_TRUST_INFO
,
394 &td
->trust_forest_trust_info
);
401 static NTSTATUS
ipasam_get_trusted_domain(struct pdb_methods
*methods
,
404 struct pdb_trusted_domain
**td
)
406 struct ldapsam_privates
*ldap_state
=
407 (struct ldapsam_privates
*)methods
->private_data
;
408 LDAPMessage
*entry
= NULL
;
410 DEBUG(10, ("ipasam_get_trusted_domain called for domain %s\n", domain
));
412 if (!get_trusted_domain_by_name_int(ldap_state
, talloc_tos(), domain
,
414 return NT_STATUS_UNSUCCESSFUL
;
417 DEBUG(5, ("ipasam_get_trusted_domain: no such trusted domain: "
419 return NT_STATUS_NO_SUCH_DOMAIN
;
422 if (!fill_pdb_trusted_domain(mem_ctx
, ldap_state
, entry
, td
)) {
423 return NT_STATUS_UNSUCCESSFUL
;
429 static NTSTATUS
ipasam_get_trusted_domain_by_sid(struct pdb_methods
*methods
,
432 struct pdb_trusted_domain
**td
)
434 struct ldapsam_privates
*ldap_state
=
435 (struct ldapsam_privates
*)methods
->private_data
;
436 LDAPMessage
*entry
= NULL
;
439 sid_str
= sid_string_tos(sid
);
441 DEBUG(10, ("ipasam_get_trusted_domain_by_sid called for sid %s\n",
444 if (!get_trusted_domain_by_sid_int(ldap_state
, talloc_tos(), sid_str
,
446 return NT_STATUS_UNSUCCESSFUL
;
449 DEBUG(5, ("ipasam_get_trusted_domain_by_sid: no trusted domain "
450 "with sid: %s\n", sid_str
));
451 return NT_STATUS_NO_SUCH_DOMAIN
;
454 if (!fill_pdb_trusted_domain(mem_ctx
, ldap_state
, entry
, td
)) {
455 return NT_STATUS_UNSUCCESSFUL
;
461 static bool smbldap_make_mod_uint32_t(LDAP
*ldap_struct
, LDAPMessage
*entry
,
462 LDAPMod
***mods
, const char *attribute
,
467 dummy
= talloc_asprintf(talloc_tos(), "%lu", (unsigned long) val
);
471 smbldap_make_mod(ldap_struct
, entry
, mods
, attribute
, dummy
);
477 static NTSTATUS
ipasam_set_trusted_domain(struct pdb_methods
*methods
,
479 const struct pdb_trusted_domain
*td
)
481 struct ldapsam_privates
*ldap_state
=
482 (struct ldapsam_privates
*)methods
->private_data
;
483 LDAPMessage
*entry
= NULL
;
486 char *trusted_dn
= NULL
;
489 DEBUG(10, ("ipasam_set_trusted_domain called for domain %s\n", domain
));
491 res
= get_trusted_domain_by_name_int(ldap_state
, talloc_tos(), domain
,
494 return NT_STATUS_UNSUCCESSFUL
;
498 smbldap_make_mod(priv2ld(ldap_state
), entry
, &mods
, "objectClass",
499 LDAP_OBJ_TRUSTED_DOMAIN
);
501 if (td
->netbios_name
!= NULL
) {
502 smbldap_make_mod(priv2ld(ldap_state
), entry
, &mods
,
503 LDAP_ATTRIBUTE_FLAT_NAME
,
507 if (td
->domain_name
!= NULL
) {
508 smbldap_make_mod(priv2ld(ldap_state
), entry
, &mods
,
509 LDAP_ATTRIBUTE_TRUST_PARTNER
,
513 if (!is_null_sid(&td
->security_identifier
)) {
514 smbldap_make_mod(priv2ld(ldap_state
), entry
, &mods
,
515 LDAP_ATTRIBUTE_SECURITY_IDENTIFIER
,
516 sid_string_tos(&td
->security_identifier
));
519 if (td
->trust_type
!= 0) {
520 res
= smbldap_make_mod_uint32_t(priv2ld(ldap_state
), entry
,
521 &mods
, LDAP_ATTRIBUTE_TRUST_TYPE
,
524 return NT_STATUS_UNSUCCESSFUL
;
528 if (td
->trust_attributes
!= 0) {
529 res
= smbldap_make_mod_uint32_t(priv2ld(ldap_state
), entry
,
531 LDAP_ATTRIBUTE_TRUST_ATTRIBUTES
,
532 td
->trust_attributes
);
534 return NT_STATUS_UNSUCCESSFUL
;
538 if (td
->trust_direction
!= 0) {
539 res
= smbldap_make_mod_uint32_t(priv2ld(ldap_state
), entry
,
541 LDAP_ATTRIBUTE_TRUST_DIRECTION
,
542 td
->trust_direction
);
544 return NT_STATUS_UNSUCCESSFUL
;
548 if (td
->trust_posix_offset
!= NULL
) {
549 res
= smbldap_make_mod_uint32_t(priv2ld(ldap_state
), entry
,
551 LDAP_ATTRIBUTE_TRUST_POSIX_OFFSET
,
552 *td
->trust_posix_offset
);
554 return NT_STATUS_UNSUCCESSFUL
;
558 if (td
->supported_enc_type
!= NULL
) {
559 res
= smbldap_make_mod_uint32_t(priv2ld(ldap_state
), entry
,
561 LDAP_ATTRIBUTE_SUPPORTED_ENC_TYPE
,
562 *td
->supported_enc_type
);
564 return NT_STATUS_UNSUCCESSFUL
;
568 if (td
->trust_auth_outgoing
.data
!= NULL
) {
569 smbldap_make_mod_blob(priv2ld(ldap_state
), entry
, &mods
,
570 LDAP_ATTRIBUTE_TRUST_AUTH_OUTGOING
,
571 &td
->trust_auth_outgoing
);
574 if (td
->trust_auth_incoming
.data
!= NULL
) {
575 smbldap_make_mod_blob(priv2ld(ldap_state
), entry
, &mods
,
576 LDAP_ATTRIBUTE_TRUST_AUTH_INCOMING
,
577 &td
->trust_auth_incoming
);
580 if (td
->trust_forest_trust_info
.data
!= NULL
) {
581 smbldap_make_mod_blob(priv2ld(ldap_state
), entry
, &mods
,
582 LDAP_ATTRIBUTE_TRUST_FOREST_TRUST_INFO
,
583 &td
->trust_forest_trust_info
);
586 talloc_autofree_ldapmod(talloc_tos(), mods
);
588 trusted_dn
= trusted_domain_dn(ldap_state
, domain
);
589 if (trusted_dn
== NULL
) {
590 return NT_STATUS_NO_MEMORY
;
593 ret
= smbldap_add(ldap_state
->smbldap_state
, trusted_dn
, mods
);
595 ret
= smbldap_modify(ldap_state
->smbldap_state
, trusted_dn
, mods
);
598 if (ret
!= LDAP_SUCCESS
) {
599 DEBUG(1, ("error writing trusted domain data!\n"));
600 return NT_STATUS_UNSUCCESSFUL
;
605 static NTSTATUS
ipasam_del_trusted_domain(struct pdb_methods
*methods
,
609 struct ldapsam_privates
*ldap_state
=
610 (struct ldapsam_privates
*)methods
->private_data
;
611 LDAPMessage
*entry
= NULL
;
614 if (!get_trusted_domain_by_name_int(ldap_state
, talloc_tos(), domain
,
616 return NT_STATUS_UNSUCCESSFUL
;
620 DEBUG(5, ("ipasam_del_trusted_domain: no such trusted domain: "
622 return NT_STATUS_NO_SUCH_DOMAIN
;
625 dn
= smbldap_talloc_dn(talloc_tos(), priv2ld(ldap_state
), entry
);
627 DEBUG(0,("ipasam_del_trusted_domain: Out of memory!\n"));
628 return NT_STATUS_NO_MEMORY
;
631 ret
= smbldap_delete(ldap_state
->smbldap_state
, dn
);
632 if (ret
!= LDAP_SUCCESS
) {
633 return NT_STATUS_UNSUCCESSFUL
;
639 static NTSTATUS
ipasam_enum_trusted_domains(struct pdb_methods
*methods
,
641 uint32_t *num_domains
,
642 struct pdb_trusted_domain
***domains
)
645 struct ldapsam_privates
*ldap_state
=
646 (struct ldapsam_privates
*)methods
->private_data
;
647 char *base_dn
= NULL
;
649 int scope
= LDAP_SCOPE_SUBTREE
;
650 LDAPMessage
*result
= NULL
;
651 LDAPMessage
*entry
= NULL
;
653 filter
= talloc_asprintf(talloc_tos(), "(objectClass=%s)",
654 LDAP_OBJ_TRUSTED_DOMAIN
);
655 if (filter
== NULL
) {
656 return NT_STATUS_NO_MEMORY
;
659 base_dn
= trusted_domain_base_dn(ldap_state
);
660 if (base_dn
== NULL
) {
662 return NT_STATUS_NO_MEMORY
;
665 rc
= smbldap_search(ldap_state
->smbldap_state
, base_dn
, scope
, filter
,
668 TALLOC_FREE(base_dn
);
670 if (result
!= NULL
) {
671 talloc_autofree_ldapmsg(mem_ctx
, result
);
674 if (rc
== LDAP_NO_SUCH_OBJECT
) {
680 if (rc
!= LDAP_SUCCESS
) {
681 return NT_STATUS_UNSUCCESSFUL
;
685 if (!(*domains
= talloc_array(mem_ctx
, struct pdb_trusted_domain
*, 1))) {
686 DEBUG(1, ("talloc failed\n"));
687 return NT_STATUS_NO_MEMORY
;
690 for (entry
= ldap_first_entry(priv2ld(ldap_state
), result
);
692 entry
= ldap_next_entry(priv2ld(ldap_state
), entry
))
694 struct pdb_trusted_domain
*dom_info
;
696 if (!fill_pdb_trusted_domain(*domains
, ldap_state
, entry
,
698 return NT_STATUS_UNSUCCESSFUL
;
701 ADD_TO_ARRAY(*domains
, struct pdb_trusted_domain
*, dom_info
,
702 domains
, num_domains
);
704 if (*domains
== NULL
) {
705 DEBUG(1, ("talloc failed\n"));
706 return NT_STATUS_NO_MEMORY
;
710 DEBUG(5, ("ipasam_enum_trusted_domains: got %d domains\n", *num_domains
));
714 static NTSTATUS
ipasam_enum_trusteddoms(struct pdb_methods
*methods
,
716 uint32_t *num_domains
,
717 struct trustdom_info
***domains
)
720 struct pdb_trusted_domain
**td
;
723 status
= ipasam_enum_trusted_domains(methods
, talloc_tos(),
725 if (!NT_STATUS_IS_OK(status
)) {
729 if (*num_domains
== 0) {
733 if (!(*domains
= talloc_array(mem_ctx
, struct trustdom_info
*,
735 DEBUG(1, ("talloc failed\n"));
736 return NT_STATUS_NO_MEMORY
;
739 for (i
= 0; i
< *num_domains
; i
++) {
740 struct trustdom_info
*dom_info
;
742 dom_info
= talloc(*domains
, struct trustdom_info
);
743 if (dom_info
== NULL
) {
744 DEBUG(1, ("talloc failed\n"));
745 return NT_STATUS_NO_MEMORY
;
748 dom_info
->name
= talloc_steal(mem_ctx
, td
[i
]->netbios_name
);
749 sid_copy(&dom_info
->sid
, &td
[i
]->security_identifier
);
751 (*domains
)[i
] = dom_info
;
757 static uint32_t pdb_ipasam_capabilities(struct pdb_methods
*methods
)
759 return PDB_CAP_STORE_RIDS
| PDB_CAP_ADS
| PDB_CAP_TRUSTED_DOMAINS_EX
;
762 static struct pdb_domain_info
*pdb_ipasam_get_domain_info(struct pdb_methods
*pdb_methods
,
765 struct pdb_domain_info
*info
;
766 struct ldapsam_privates
*ldap_state
=
767 (struct ldapsam_privates
*)pdb_methods
->private_data
;
772 info
= talloc(mem_ctx
, struct pdb_domain_info
);
777 info
->name
= talloc_strdup(info
, ldap_state
->domain_name
);
778 if (info
->name
== NULL
) {
782 /* TODO: read dns_domain, dns_forest and guid from LDAP */
783 info
->dns_domain
= talloc_strdup(info
, lp_realm());
784 if (info
->dns_domain
== NULL
) {
787 strlower_m(info
->dns_domain
);
788 info
->dns_forest
= talloc_strdup(info
, info
->dns_domain
);
790 /* we expect a domain SID to have 4 sub IDs */
791 if (ldap_state
->domain_sid
.num_auths
!= 4) {
795 sid_copy(&info
->sid
, &ldap_state
->domain_sid
);
797 if (!sid_linearize(sid_buf
, sizeof(sid_buf
), &info
->sid
)) {
801 /* the first 8 bytes of the linearized SID are not random,
803 sid_blob
.data
= (uint8_t *) sid_buf
+ 8 ;
804 sid_blob
.length
= 16;
806 status
= GUID_from_ndr_blob(&sid_blob
, &info
->guid
);
807 if (!NT_STATUS_IS_OK(status
)) {
818 static NTSTATUS
modify_ipa_password_exop(struct ldapsam_privates
*ldap_state
,
819 struct samu
*sampass
)
822 BerElement
*ber
= NULL
;
823 struct berval
*bv
= NULL
;
825 struct berval
*retdata
= NULL
;
826 const char *password
;
829 password
= pdb_get_plaintext_passwd(sampass
);
830 if (password
== NULL
|| *password
== '\0') {
831 return NT_STATUS_INVALID_PARAMETER
;
834 dn
= get_account_dn(pdb_get_username(sampass
));
836 return NT_STATUS_INVALID_PARAMETER
;
839 ber
= ber_alloc_t( LBER_USE_DER
);
841 DEBUG(7, ("ber_alloc_t failed.\n"));
842 return NT_STATUS_NO_MEMORY
;
845 ret
= ber_printf(ber
, "{tsts}", LDAP_TAG_EXOP_MODIFY_PASSWD_ID
, dn
,
846 LDAP_TAG_EXOP_MODIFY_PASSWD_NEW
, password
);
848 DEBUG(7, ("ber_printf failed.\n"));
850 return NT_STATUS_UNSUCCESSFUL
;
853 ret
= ber_flatten(ber
, &bv
);
856 DEBUG(1, ("ber_flatten failed.\n"));
857 return NT_STATUS_UNSUCCESSFUL
;
860 ret
= smbldap_extended_operation(ldap_state
->smbldap_state
,
861 LDAP_EXOP_MODIFY_PASSWD
, bv
, NULL
,
862 NULL
, &retoid
, &retdata
);
868 ldap_memfree(retoid
);
870 if (ret
!= LDAP_SUCCESS
) {
871 DEBUG(1, ("smbldap_extended_operation LDAP_EXOP_MODIFY_PASSWD failed.\n"));
872 return NT_STATUS_UNSUCCESSFUL
;
878 static NTSTATUS
ipasam_get_objectclasses(struct ldapsam_privates
*ldap_state
,
879 const char *dn
, LDAPMessage
*entry
,
880 uint32_t *has_objectclass
)
882 char **objectclasses
;
885 objectclasses
= ldap_get_values(priv2ld(ldap_state
), entry
,
886 LDAP_ATTRIBUTE_OBJECTCLASS
);
887 if (objectclasses
== NULL
) {
888 DEBUG(0, ("Entry [%s] does not have any objectclasses.\n", dn
));
889 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
892 *has_objectclass
= 0;
893 for (c
= 0; objectclasses
[c
] != NULL
; c
++) {
894 if (strequal(objectclasses
[c
], LDAP_OBJ_KRB_PRINCIPAL
)) {
895 *has_objectclass
|= HAS_KRB_PRINCIPAL
;
896 } else if (strequal(objectclasses
[c
],
897 LDAP_OBJ_KRB_PRINCIPAL_AUX
)) {
898 *has_objectclass
|= HAS_KRB_PRINCIPAL_AUX
;
899 } else if (strequal(objectclasses
[c
], LDAP_OBJ_IPAOBJECT
)) {
900 *has_objectclass
|= HAS_IPAOBJECT
;
901 } else if (strequal(objectclasses
[c
], LDAP_OBJ_IPAHOST
)) {
902 *has_objectclass
|= HAS_IPAHOST
;
903 } else if (strequal(objectclasses
[c
], LDAP_OBJ_POSIXACCOUNT
)) {
904 *has_objectclass
|= HAS_POSIXACCOUNT
;
905 } else if (strequal(objectclasses
[c
], LDAP_OBJ_GROUPOFNAMES
)) {
906 *has_objectclass
|= HAS_GROUPOFNAMES
;
907 } else if (strequal(objectclasses
[c
], LDAP_OBJ_NESTEDGROUP
)) {
908 *has_objectclass
|= HAS_NESTEDGROUP
;
909 } else if (strequal(objectclasses
[c
], LDAP_OBJ_IPAUSERGROUP
)) {
910 *has_objectclass
|= HAS_IPAUSERGROUP
;
911 } else if (strequal(objectclasses
[c
], LDAP_OBJ_POSIXGROUP
)) {
912 *has_objectclass
|= HAS_POSIXGROUP
;
915 ldap_value_free(objectclasses
);
926 static NTSTATUS
find_obj(struct ldapsam_privates
*ldap_state
, const char *name
,
927 enum obj_type type
, char **_dn
,
928 uint32_t *_has_objectclass
)
933 LDAPMessage
*result
= NULL
;
934 LDAPMessage
*entry
= NULL
;
937 uint32_t has_objectclass
;
939 const char *obj_class
= NULL
;
943 obj_class
= LDAP_OBJ_POSIXACCOUNT
;
946 obj_class
= LDAP_OBJ_POSIXGROUP
;
949 DEBUG(0, ("Unsupported IPA object.\n"));
950 return NT_STATUS_INVALID_PARAMETER
;
953 username
= escape_ldap_string(talloc_tos(), name
);
954 if (username
== NULL
) {
955 return NT_STATUS_NO_MEMORY
;
957 filter
= talloc_asprintf(talloc_tos(), "(&(uid=%s)(objectClass=%s))",
958 username
, obj_class
);
959 if (filter
== NULL
) {
960 return NT_STATUS_NO_MEMORY
;
962 TALLOC_FREE(username
);
964 ret
= smbldap_search_suffix(ldap_state
->smbldap_state
, filter
, NULL
,
966 if (ret
!= LDAP_SUCCESS
) {
967 DEBUG(0, ("smbldap_search_suffix failed.\n"));
968 return NT_STATUS_ACCESS_DENIED
;
971 num_result
= ldap_count_entries(priv2ld(ldap_state
), result
);
973 if (num_result
!= 1) {
974 if (num_result
== 0) {
977 status
= NT_STATUS_NO_SUCH_USER
;
980 status
= NT_STATUS_NO_SUCH_GROUP
;
983 status
= NT_STATUS_INVALID_PARAMETER
;
986 DEBUG (0, ("find_user: More than one object with name [%s] ?!\n",
988 status
= NT_STATUS_INTERNAL_DB_CORRUPTION
;
993 entry
= ldap_first_entry(priv2ld(ldap_state
), result
);
995 DEBUG(0,("find_user: Out of memory!\n"));
996 status
= NT_STATUS_UNSUCCESSFUL
;
1000 dn
= smbldap_talloc_dn(talloc_tos(), priv2ld(ldap_state
), entry
);
1002 DEBUG(0,("find_user: Out of memory!\n"));
1003 status
= NT_STATUS_NO_MEMORY
;
1007 status
= ipasam_get_objectclasses(ldap_state
, dn
, entry
, &has_objectclass
);
1008 if (!NT_STATUS_IS_OK(status
)) {
1013 *_has_objectclass
= has_objectclass
;
1015 status
= NT_STATUS_OK
;
1018 ldap_msgfree(result
);
1023 static NTSTATUS
find_user(struct ldapsam_privates
*ldap_state
, const char *name
,
1024 char **_dn
, uint32_t *_has_objectclass
)
1026 return find_obj(ldap_state
, name
, IPA_USER_OBJ
, _dn
, _has_objectclass
);
1029 static NTSTATUS
find_group(struct ldapsam_privates
*ldap_state
, const char *name
,
1030 char **_dn
, uint32_t *_has_objectclass
)
1032 return find_obj(ldap_state
, name
, IPA_GROUP_OBJ
, _dn
, _has_objectclass
);
1035 static NTSTATUS
ipasam_add_posix_account_objectclass(struct ldapsam_privates
*ldap_state
,
1038 const char *username
)
1041 LDAPMod
**mods
= NULL
;
1043 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1044 "objectclass", "posixAccount");
1045 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1047 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1048 "uidNumber", IPA_MAGIC_ID_STR
);
1049 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1050 "gidNumber", "12345");
1051 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1052 "homeDirectory", "/dev/null");
1054 if (ldap_op
== LDAP_MOD_ADD
) {
1055 ret
= smbldap_add(ldap_state
->smbldap_state
, dn
, mods
);
1057 ret
= smbldap_modify(ldap_state
->smbldap_state
, dn
, mods
);
1059 ldap_mods_free(mods
, 1);
1060 if (ret
!= LDAP_SUCCESS
) {
1061 DEBUG(1, ("failed to modify/add user with uid = %s (dn = %s)\n",
1063 return NT_STATUS_LDAP(ret
);
1066 return NT_STATUS_OK
;
1069 static NTSTATUS
ipasam_add_ipa_group_objectclasses(struct ldapsam_privates
*ldap_state
,
1072 uint32_t has_objectclass
)
1074 LDAPMod
**mods
= NULL
;
1077 if (!(has_objectclass
& HAS_GROUPOFNAMES
)) {
1078 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1079 LDAP_ATTRIBUTE_OBJECTCLASS
,
1080 LDAP_OBJ_GROUPOFNAMES
);
1083 if (!(has_objectclass
& HAS_NESTEDGROUP
)) {
1084 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1085 LDAP_ATTRIBUTE_OBJECTCLASS
,
1086 LDAP_OBJ_NESTEDGROUP
);
1089 if (!(has_objectclass
& HAS_IPAUSERGROUP
)) {
1090 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1091 LDAP_ATTRIBUTE_OBJECTCLASS
,
1092 LDAP_OBJ_IPAUSERGROUP
);
1095 if (!(has_objectclass
& HAS_IPAOBJECT
)) {
1096 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1097 LDAP_ATTRIBUTE_OBJECTCLASS
,
1098 LDAP_OBJ_IPAOBJECT
);
1101 if (!(has_objectclass
& HAS_POSIXGROUP
)) {
1102 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1103 LDAP_ATTRIBUTE_OBJECTCLASS
,
1104 LDAP_OBJ_POSIXGROUP
);
1105 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1108 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1109 LDAP_ATTRIBUTE_GIDNUMBER
,
1113 ret
= smbldap_modify(ldap_state
->smbldap_state
, dn
, mods
);
1114 ldap_mods_free(mods
, 1);
1115 if (ret
!= LDAP_SUCCESS
) {
1116 DEBUG(1, ("failed to modify/add group %s (dn = %s)\n",
1118 return NT_STATUS_LDAP(ret
);
1121 return NT_STATUS_OK
;
1124 static NTSTATUS
ipasam_add_ipa_objectclasses(struct ldapsam_privates
*ldap_state
,
1125 const char *dn
, const char *name
,
1127 uint32_t acct_flags
,
1128 uint32_t has_objectclass
)
1130 LDAPMod
**mods
= NULL
;
1134 if (!(has_objectclass
& HAS_KRB_PRINCIPAL
)) {
1135 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1136 LDAP_ATTRIBUTE_OBJECTCLASS
,
1137 LDAP_OBJ_KRB_PRINCIPAL
);
1139 princ
= talloc_asprintf(talloc_tos(), "%s@%s", name
, lp_realm());
1140 if (princ
== NULL
) {
1141 return NT_STATUS_NO_MEMORY
;
1144 smbldap_set_mod(&mods
, LDAP_MOD_ADD
, LDAP_ATTRIBUTE_KRB_PRINCIPAL
, princ
);
1147 if (!(has_objectclass
& HAS_KRB_PRINCIPAL_AUX
)) {
1148 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1149 LDAP_ATTRIBUTE_OBJECTCLASS
,
1150 LDAP_OBJ_KRB_PRINCIPAL_AUX
);
1153 if (!(has_objectclass
& HAS_IPAOBJECT
)) {
1154 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1155 LDAP_ATTRIBUTE_OBJECTCLASS
, LDAP_OBJ_IPAOBJECT
);
1158 if ((acct_flags
!= 0) &&
1159 (((acct_flags
& ACB_NORMAL
) && name
[strlen(name
)-1] == '$') ||
1160 ((acct_flags
& (ACB_WSTRUST
|ACB_SVRTRUST
|ACB_DOMTRUST
)) != 0))) {
1162 if (!(has_objectclass
& HAS_IPAHOST
)) {
1163 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1164 LDAP_ATTRIBUTE_OBJECTCLASS
,
1167 if (domain
== NULL
) {
1168 return NT_STATUS_INVALID_PARAMETER
;
1171 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1176 if (!(has_objectclass
& HAS_POSIXACCOUNT
)) {
1177 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1178 "objectclass", "posixAccount");
1179 smbldap_set_mod(&mods
, LDAP_MOD_ADD
, "cn", name
);
1180 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1181 "uidNumber", IPA_MAGIC_ID_STR
);
1182 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1183 "gidNumber", "12345");
1184 smbldap_set_mod(&mods
, LDAP_MOD_ADD
,
1185 "homeDirectory", "/dev/null");
1189 ret
= smbldap_modify(ldap_state
->smbldap_state
, dn
, mods
);
1190 ldap_mods_free(mods
, 1);
1191 if (ret
!= LDAP_SUCCESS
) {
1192 DEBUG(1, ("failed to modify/add user with uid = %s (dn = %s)\n",
1194 return NT_STATUS_LDAP(ret
);
1198 return NT_STATUS_OK
;
1201 static NTSTATUS
pdb_ipasam_add_sam_account(struct pdb_methods
*pdb_methods
,
1202 struct samu
*sampass
)
1205 struct ldapsam_privates
*ldap_state
;
1208 uint32_t has_objectclass
;
1210 struct dom_sid user_sid
;
1212 ldap_state
= (struct ldapsam_privates
*)(pdb_methods
->private_data
);
1214 if (IS_SAM_SET(sampass
, PDB_USERSID
) ||
1215 IS_SAM_CHANGED(sampass
, PDB_USERSID
)) {
1216 if (!pdb_new_rid(&rid
)) {
1217 return NT_STATUS_DS_NO_MORE_RIDS
;
1219 sid_compose(&user_sid
, get_global_sam_sid(), rid
);
1220 if (!pdb_set_user_sid(sampass
, &user_sid
, PDB_SET
)) {
1221 return NT_STATUS_UNSUCCESSFUL
;
1225 status
= ldap_state
->ipasam_privates
->ldapsam_add_sam_account(pdb_methods
,
1227 if (!NT_STATUS_IS_OK(status
)) {
1231 if (ldap_state
->ipasam_privates
->server_is_ipa
) {
1232 name
= pdb_get_username(sampass
);
1233 if (name
== NULL
|| *name
== '\0') {
1234 return NT_STATUS_INVALID_PARAMETER
;
1237 status
= find_user(ldap_state
, name
, &dn
, &has_objectclass
);
1238 if (!NT_STATUS_IS_OK(status
)) {
1242 status
= ipasam_add_ipa_objectclasses(ldap_state
, dn
, name
,
1243 pdb_get_domain(sampass
),
1244 pdb_get_acct_ctrl(sampass
),
1246 if (!NT_STATUS_IS_OK(status
)) {
1250 if (!(has_objectclass
& HAS_POSIXACCOUNT
)) {
1251 status
= ipasam_add_posix_account_objectclass(ldap_state
,
1254 if (!NT_STATUS_IS_OK(status
)) {
1259 if (pdb_get_init_flags(sampass
, PDB_PLAINTEXT_PW
) == PDB_CHANGED
) {
1260 status
= modify_ipa_password_exop(ldap_state
, sampass
);
1261 if (!NT_STATUS_IS_OK(status
)) {
1267 return NT_STATUS_OK
;
1270 static NTSTATUS
pdb_ipasam_update_sam_account(struct pdb_methods
*pdb_methods
,
1271 struct samu
*sampass
)
1274 struct ldapsam_privates
*ldap_state
;
1275 ldap_state
= (struct ldapsam_privates
*)(pdb_methods
->private_data
);
1277 status
= ldap_state
->ipasam_privates
->ldapsam_update_sam_account(pdb_methods
,
1279 if (!NT_STATUS_IS_OK(status
)) {
1283 if (ldap_state
->ipasam_privates
->server_is_ipa
) {
1284 if (pdb_get_init_flags(sampass
, PDB_PLAINTEXT_PW
) == PDB_CHANGED
) {
1285 status
= modify_ipa_password_exop(ldap_state
, sampass
);
1286 if (!NT_STATUS_IS_OK(status
)) {
1292 return NT_STATUS_OK
;
1295 static NTSTATUS
ipasam_create_dom_group(struct pdb_methods
*pdb_methods
,
1296 TALLOC_CTX
*tmp_ctx
, const char *name
,
1300 struct ldapsam_privates
*ldap_state
;
1301 int ldap_op
= LDAP_MOD_REPLACE
;
1303 uint32_t has_objectclass
= 0;
1305 ldap_state
= (struct ldapsam_privates
*)(pdb_methods
->private_data
);
1307 if (name
== NULL
|| *name
== '\0') {
1308 return NT_STATUS_INVALID_PARAMETER
;
1311 status
= find_group(ldap_state
, name
, &dn
, &has_objectclass
);
1312 if (NT_STATUS_IS_OK(status
)) {
1313 ldap_op
= LDAP_MOD_REPLACE
;
1314 } else if (NT_STATUS_EQUAL(status
, NT_STATUS_NO_SUCH_USER
)) {
1315 ldap_op
= LDAP_MOD_ADD
;
1320 if (!(has_objectclass
& HAS_POSIXGROUP
)) {
1321 status
= ipasam_add_ipa_group_objectclasses(ldap_state
, dn
,
1324 if (!NT_STATUS_IS_OK(status
)) {
1329 status
= ldap_state
->ipasam_privates
->ldapsam_create_dom_group(pdb_methods
,
1333 if (!NT_STATUS_IS_OK(status
)) {
1337 return NT_STATUS_OK
;
1339 static NTSTATUS
ipasam_create_user(struct pdb_methods
*pdb_methods
,
1340 TALLOC_CTX
*tmp_ctx
, const char *name
,
1341 uint32_t acb_info
, uint32_t *rid
)
1344 struct ldapsam_privates
*ldap_state
;
1345 int ldap_op
= LDAP_MOD_REPLACE
;
1347 uint32_t has_objectclass
= 0;
1349 ldap_state
= (struct ldapsam_privates
*)(pdb_methods
->private_data
);
1351 if (name
== NULL
|| *name
== '\0') {
1352 return NT_STATUS_INVALID_PARAMETER
;
1355 status
= find_user(ldap_state
, name
, &dn
, &has_objectclass
);
1356 if (NT_STATUS_IS_OK(status
)) {
1357 ldap_op
= LDAP_MOD_REPLACE
;
1358 } else if (NT_STATUS_EQUAL(status
, NT_STATUS_NO_SUCH_USER
)) {
1359 char *escape_username
;
1360 ldap_op
= LDAP_MOD_ADD
;
1361 escape_username
= escape_rdn_val_string_alloc(name
);
1362 if (!escape_username
) {
1363 return NT_STATUS_NO_MEMORY
;
1365 if (name
[strlen(name
)-1] == '$') {
1366 dn
= talloc_asprintf(tmp_ctx
, "uid=%s,%s",
1368 lp_ldap_machine_suffix());
1370 dn
= talloc_asprintf(tmp_ctx
, "uid=%s,%s",
1372 lp_ldap_user_suffix());
1374 SAFE_FREE(escape_username
);
1376 return NT_STATUS_NO_MEMORY
;
1382 if (!(has_objectclass
& HAS_POSIXACCOUNT
)) {
1383 status
= ipasam_add_posix_account_objectclass(ldap_state
, ldap_op
,
1385 if (!NT_STATUS_IS_OK(status
)) {
1388 has_objectclass
|= HAS_POSIXACCOUNT
;
1391 status
= ldap_state
->ipasam_privates
->ldapsam_create_user(pdb_methods
,
1394 if (!NT_STATUS_IS_OK(status
)) {
1398 status
= ipasam_add_ipa_objectclasses(ldap_state
, dn
, name
, lp_realm(),
1399 acb_info
, has_objectclass
);
1400 if (!NT_STATUS_IS_OK(status
)) {
1404 return NT_STATUS_OK
;
1407 static NTSTATUS
pdb_init_IPA_ldapsam(struct pdb_methods
**pdb_method
, const char *location
)
1409 struct ldapsam_privates
*ldap_state
;
1412 status
= pdb_init_ldapsam(pdb_method
, location
);
1413 if (!NT_STATUS_IS_OK(status
)) {
1417 (*pdb_method
)->name
= "IPA_ldapsam";
1419 ldap_state
= (struct ldapsam_privates
*)((*pdb_method
)->private_data
);
1420 ldap_state
->ipasam_privates
= talloc_zero(ldap_state
,
1421 struct ipasam_privates
);
1422 if (ldap_state
->ipasam_privates
== NULL
) {
1423 return NT_STATUS_NO_MEMORY
;
1425 ldap_state
->is_ipa_ldap
= True
;
1427 ldap_state
->ipasam_privates
->server_is_ipa
= smbldap_has_extension(
1428 priv2ld(ldap_state
), IPA_KEYTAB_SET_OID
);
1429 ldap_state
->ipasam_privates
->ldapsam_add_sam_account
= (*pdb_method
)->add_sam_account
;
1430 ldap_state
->ipasam_privates
->ldapsam_update_sam_account
= (*pdb_method
)->update_sam_account
;
1431 ldap_state
->ipasam_privates
->ldapsam_create_user
= (*pdb_method
)->create_user
;
1432 ldap_state
->ipasam_privates
->ldapsam_create_dom_group
= (*pdb_method
)->create_dom_group
;
1434 (*pdb_method
)->add_sam_account
= pdb_ipasam_add_sam_account
;
1435 (*pdb_method
)->update_sam_account
= pdb_ipasam_update_sam_account
;
1437 if (lp_parm_bool(-1, "ldapsam", "trusted", False
)) {
1438 if (lp_parm_bool(-1, "ldapsam", "editposix", False
)) {
1439 (*pdb_method
)->create_user
= ipasam_create_user
;
1440 (*pdb_method
)->create_dom_group
= ipasam_create_dom_group
;
1444 (*pdb_method
)->capabilities
= pdb_ipasam_capabilities
;
1445 (*pdb_method
)->get_domain_info
= pdb_ipasam_get_domain_info
;
1447 (*pdb_method
)->get_trusteddom_pw
= ipasam_get_trusteddom_pw
;
1448 (*pdb_method
)->set_trusteddom_pw
= ipasam_set_trusteddom_pw
;
1449 (*pdb_method
)->del_trusteddom_pw
= ipasam_del_trusteddom_pw
;
1450 (*pdb_method
)->enum_trusteddoms
= ipasam_enum_trusteddoms
;
1452 (*pdb_method
)->get_trusted_domain
= ipasam_get_trusted_domain
;
1453 (*pdb_method
)->get_trusted_domain_by_sid
= ipasam_get_trusted_domain_by_sid
;
1454 (*pdb_method
)->set_trusted_domain
= ipasam_set_trusted_domain
;
1455 (*pdb_method
)->del_trusted_domain
= ipasam_del_trusted_domain
;
1456 (*pdb_method
)->enum_trusted_domains
= ipasam_enum_trusted_domains
;
1458 return NT_STATUS_OK
;
1461 NTSTATUS
pdb_ipa_init(void)
1465 if (!NT_STATUS_IS_OK(nt_status
= smb_register_passdb(PASSDB_INTERFACE_VERSION
, "IPA_ldapsam", pdb_init_IPA_ldapsam
)))
1468 return NT_STATUS_OK
;