s4:rootdse LDB module - introduce dynamic "ldapServiceName"
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 18 Sep 2010 19:44:26 +0000 (21:44 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 23 Sep 2010 23:25:43 +0000 (09:25 +1000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/rootdse.c

index 041e85840ed5c871d579bb0c30aca6fae55883dd..a786a70ce319983a0c2844f0a9b968e907834f2f 100644 (file)
@@ -206,6 +206,31 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
                }
        }
 
+       if (do_attribute(attrs, "ldapServiceName")) {
+               struct loadparm_context *lp_ctx
+                       = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
+                                         struct loadparm_context);
+               char *ldap_service_name, *hostname;
+
+               hostname = talloc_strdup(msg, lpcfg_netbios_name(lp_ctx));
+               if (hostname == NULL) {
+                       goto failed;
+               }
+               strlower_m(hostname);
+
+               ldap_service_name = talloc_asprintf(msg, "%s:%s$@%s",
+                                                   samdb_forest_name(ldb, msg),
+                                                   hostname, lpcfg_realm(lp_ctx));
+               if (ldap_service_name == NULL) {
+                       goto failed;
+               }
+
+               if (ldb_msg_add_string(msg, "ldapServiceName",
+                                      ldap_service_name) != LDB_SUCCESS) {
+                       goto failed;
+               }
+       }
+
        if (do_attribute(attrs, "currentTime")) {
                if (ldb_msg_add_steal_string(msg, "currentTime",
                                             ldb_timestring(msg, time(NULL))) != LDB_SUCCESS) {