Add msDS-AdditionalDnsHostName entries to the keytab
[samba.git] / source3 / libads / ldap.c
index 0caa104464576ef593f642cde5e0292f1a06352e..eb5fef0c7f39175c4535d8338470870c85c10baf 100755 (executable)
@@ -1377,6 +1377,7 @@ char *ads_parent_dn(const char *dn)
                "unicodePwd",
 
                /* Additional attributes Samba checks */
+               "msDS-AdditionalDnsHostName",
                "msDS-SupportedEncryptionTypes",
                "nTSecurityDescriptor",
 
@@ -3668,6 +3669,50 @@ out:
 /********************************************************************
 ********************************************************************/
 
+ADS_STATUS ads_get_additional_dns_hostnames(TALLOC_CTX *mem_ctx,
+                                           ADS_STRUCT *ads,
+                                           const char *machine_name,
+                                           char ***hostnames_array,
+                                           size_t *num_hostnames)
+{
+       ADS_STATUS status;
+       LDAPMessage *res = NULL;
+       int count;
+
+       status = ads_find_machine_acct(ads,
+                                      &res,
+                                      machine_name);
+       if (!ADS_ERR_OK(status)) {
+               DEBUG(1,("Host Account for %s not found... skipping operation.\n",
+                        machine_name));
+               return status;
+       }
+
+       count = ads_count_replies(ads, res);
+       if (count != 1) {
+               status = ADS_ERROR(LDAP_NO_SUCH_OBJECT);
+               goto done;
+       }
+
+       *hostnames_array = ads_pull_strings(ads, mem_ctx, res,
+                                           "msDS-AdditionalDnsHostName",
+                                           num_hostnames);
+       if (*hostnames_array == NULL) {
+               DEBUG(1, ("Host account for %s does not have msDS-AdditionalDnsHostName.\n",
+                         machine_name));
+               status = ADS_ERROR(LDAP_NO_SUCH_OBJECT);
+               goto done;
+       }
+
+done:
+       ads_msgfree(ads, res);
+
+       return status;
+}
+
+/********************************************************************
+********************************************************************/
+
 char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name )
 {
        LDAPMessage *res = NULL;