r25026: Move param/param.h out of includes.h
[kai/samba-autobuild/.git] / source4 / rpc_server / lsa / dcesrv_lsa.c
index 4a207645b4944eec11eee6d1c5e99fb0729ab551..144e61cd75dedf4c35e947ca87fac0ce24e1558d 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -33,6 +32,7 @@
 #include "param/secrets.h"
 #include "db_wrap.h"
 #include "librpc/gen_ndr/ndr_dssetup.h"
+#include "param/param.h"
 
 /*
   this type allows us to distinguish handle types
@@ -53,10 +53,12 @@ struct lsa_policy_state {
        struct sidmap_context *sidmap;
        uint32_t access_mask;
        struct ldb_dn *domain_dn;
+       struct ldb_dn *forest_dn;
        struct ldb_dn *builtin_dn;
        struct ldb_dn *system_dn;
        const char *domain_name;
        const char *domain_dns;
+       const char *forest_dns;
        struct dom_sid *domain_sid;
        struct GUID domain_guid;
        struct dom_sid *builtin_sid;
@@ -94,11 +96,11 @@ struct lsa_trusted_domain_state {
        struct ldb_dn *trusted_domain_dn;
 };
 
-static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, 
                                      TALLOC_CTX *mem_ctx,
                                      struct lsa_EnumAccountRights *r);
 
-static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call, 
                                           TALLOC_CTX *mem_ctx,
                                           struct lsa_policy_state *state,
                                           int ldb_flag,
@@ -108,7 +110,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
 /* 
   lsa_Close 
 */
-static NTSTATUS lsa_Close(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_Close(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                          struct lsa_Close *r)
 {
        struct dcesrv_handle *h;
@@ -128,7 +130,7 @@ static NTSTATUS lsa_Close(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ct
 /* 
   lsa_Delete 
 */
-static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                           struct lsa_Delete *r)
 {
        struct dcesrv_handle *h;
@@ -170,7 +172,7 @@ static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c
                r2.in.sid = astate->account_sid;
                r2.out.rights = rights;
 
-               status = lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
+               status = dcesrv_lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
                if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
                        return NT_STATUS_OK;
                }
@@ -179,7 +181,7 @@ static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c
                        return status;
                }
 
-               status = lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
+               status = dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
                                                    LDB_FLAG_MOD_DELETE, astate->account_sid,
                                                    r2.out.rights);
                if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
@@ -198,7 +200,7 @@ static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c
 /* 
   lsa_EnumPrivs 
 */
-static NTSTATUS lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                              struct lsa_EnumPrivs *r)
 {
        struct dcesrv_handle *h;
@@ -241,7 +243,7 @@ static NTSTATUS lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 /* 
   lsa_QuerySecObj 
 */
-static NTSTATUS lsa_QuerySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QuerySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                  struct lsa_QuerySecurity *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -251,7 +253,7 @@ static NTSTATUS lsa_QuerySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_SetSecObj 
 */
-static NTSTATUS lsa_SetSecObj(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetSecObj(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                              struct lsa_SetSecObj *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -261,13 +263,13 @@ static NTSTATUS lsa_SetSecObj(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 /* 
   lsa_ChangePassword 
 */
-static NTSTATUS lsa_ChangePassword(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_ChangePassword(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                   struct lsa_ChangePassword *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
 }
 
-static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                     struct lsa_policy_state **_state)
 {
        struct lsa_policy_state *state;
@@ -281,6 +283,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
                NULL
        };
        struct ldb_result *ref_res;
+       struct ldb_result *forest_ref_res;
        const char *ref_attrs[] = {
                "nETBIOSName",
                "dnsRoot",
@@ -313,6 +316,13 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
                return NT_STATUS_NO_MEMORY;             
        }
 
+       /* work out the forest root_dn - useful for so many calls its worth
+          fetching here */
+       state->forest_dn = samdb_root_dn(state->sam_ldb);
+       if (!state->forest_dn) {
+               return NT_STATUS_NO_MEMORY;             
+       }
+
        ret = ldb_search(state->sam_ldb, state->domain_dn, LDB_SCOPE_BASE, NULL, dom_attrs, &dom_res);
        
        if (ret != LDB_SUCCESS) {
@@ -367,6 +377,29 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
 
        talloc_free(ref_res);
 
+       ret = ldb_search_exp_fmt(state->sam_ldb, state, &forest_ref_res,
+                                partitions_basedn, LDB_SCOPE_SUBTREE, ref_attrs,
+                                "(&(objectclass=crossRef)(ncName=%s))",
+                                ldb_dn_get_linearized(state->forest_dn));
+       
+       if (ret != LDB_SUCCESS) {
+               talloc_free(forest_ref_res);
+               return NT_STATUS_INVALID_SYSTEM_SERVICE;
+       }
+       if (forest_ref_res->count != 1) {
+               talloc_free(forest_ref_res);
+               return NT_STATUS_NO_SUCH_DOMAIN;                
+       }
+
+       state->forest_dns = ldb_msg_find_attr_as_string(forest_ref_res->msgs[0], "dnsRoot", NULL);
+       if (!state->forest_dns) {
+               talloc_free(forest_ref_res);
+               return NT_STATUS_NO_SUCH_DOMAIN;                
+       }
+       talloc_steal(state, state->forest_dns);
+
+       talloc_free(forest_ref_res);
+
        /* work out the builtin_dn - useful for so many calls its worth
           fetching here */
        state->builtin_dn = samdb_search_dn(state->sam_ldb, state, state->domain_dn, "(objectClass=builtinDomain)");
@@ -398,7 +431,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
   This is not an LSA call, but is the only call left on the DSSETUP
   pipe (after the pipe was truncated), and needs lsa_get_policy_state
 */
-static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call, 
+static WERROR dcesrv_dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call, 
                                                 TALLOC_CTX *mem_ctx,
                                                 struct dssetup_DsRoleGetPrimaryDomainInformation *r)
 {
@@ -418,7 +451,7 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
                struct GUID domain_guid;
                struct lsa_policy_state *state;
 
-               NTSTATUS status = lsa_get_policy_state(dce_call, mem_ctx, &state);
+               NTSTATUS status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
                if (!NT_STATUS_IS_OK(status)) {
                        return ntstatus_to_werror(status);
                }
@@ -460,7 +493,7 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
                        
                        domain          = state->domain_name;
                        dns_domain      = state->domain_dns;
-                       forest          = state->domain_dns;
+                       forest          = state->forest_dns;
 
                        domain_guid     = state->domain_guid;
                        flags   |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
@@ -502,7 +535,7 @@ static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state
 /* 
   lsa_OpenPolicy2
 */
-static NTSTATUS lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                               struct lsa_OpenPolicy2 *r)
 {
        NTSTATUS status;
@@ -511,7 +544,7 @@ static NTSTATUS lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 
        ZERO_STRUCTP(r->out.handle);
 
-       status = lsa_get_policy_state(dce_call, mem_ctx, &state);
+       status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -538,7 +571,7 @@ static NTSTATUS lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *
   lsa_OpenPolicy
   a wrapper around lsa_OpenPolicy2
 */
-static NTSTATUS lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                struct lsa_OpenPolicy *r)
 {
        struct lsa_OpenPolicy2 r2;
@@ -548,7 +581,7 @@ static NTSTATUS lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
        r2.in.access_mask = r->in.access_mask;
        r2.out.handle = r->out.handle;
 
-       return lsa_OpenPolicy2(dce_call, mem_ctx, &r2);
+       return dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &r2);
 }
 
 
@@ -557,7 +590,7 @@ static NTSTATUS lsa_OpenPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
 /*
   fill in the AccountDomain info
 */
-static NTSTATUS lsa_info_AccountDomain(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_info_AccountDomain(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
                                       struct lsa_DomainInfo *info)
 {
        info->name.string = state->domain_name;
@@ -569,13 +602,13 @@ static NTSTATUS lsa_info_AccountDomain(struct lsa_policy_state *state, TALLOC_CT
 /*
   fill in the DNS domain info
 */
-static NTSTATUS lsa_info_DNS(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_info_DNS(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
                             struct lsa_DnsDomainInfo *info)
 {
        info->name.string = state->domain_name;
        info->sid         = state->domain_sid;
        info->dns_domain.string = state->domain_dns;
-       info->dns_forest.string = state->domain_dns;
+       info->dns_forest.string = state->forest_dns;
        info->domain_guid       = state->domain_guid;
 
        return NT_STATUS_OK;
@@ -584,7 +617,7 @@ static NTSTATUS lsa_info_DNS(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx
 /* 
   lsa_QueryInfoPolicy2
 */
-static NTSTATUS lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                     struct lsa_QueryInfoPolicy2 *r)
 {
        struct lsa_policy_state *state;
@@ -606,10 +639,10 @@ static NTSTATUS lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call, TALLOC_
        switch (r->in.level) {
        case LSA_POLICY_INFO_DOMAIN:
        case LSA_POLICY_INFO_ACCOUNT_DOMAIN:
-               return lsa_info_AccountDomain(state, mem_ctx, &r->out.info->account_domain);
+               return dcesrv_lsa_info_AccountDomain(state, mem_ctx, &r->out.info->account_domain);
 
        case LSA_POLICY_INFO_DNS:
-               return lsa_info_DNS(state, mem_ctx, &r->out.info->dns);
+               return dcesrv_lsa_info_DNS(state, mem_ctx, &r->out.info->dns);
        }
 
        return NT_STATUS_INVALID_INFO_CLASS;
@@ -618,7 +651,7 @@ static NTSTATUS lsa_QueryInfoPolicy2(struct dcesrv_call_state *dce_call, TALLOC_
 /* 
   lsa_QueryInfoPolicy 
 */
-static NTSTATUS lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                    struct lsa_QueryInfoPolicy *r)
 {
        struct lsa_QueryInfoPolicy2 r2;
@@ -627,7 +660,7 @@ static NTSTATUS lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_C
        r2.in.handle = r->in.handle;
        r2.in.level = r->in.level;
        
-       status = lsa_QueryInfoPolicy2(dce_call, mem_ctx, &r2);
+       status = dcesrv_lsa_QueryInfoPolicy2(dce_call, mem_ctx, &r2);
 
        r->out.info = r2.out.info;
 
@@ -637,7 +670,7 @@ static NTSTATUS lsa_QueryInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_C
 /* 
   lsa_SetInfoPolicy 
 */
-static NTSTATUS lsa_SetInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                  struct lsa_SetInfoPolicy *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -647,7 +680,7 @@ static NTSTATUS lsa_SetInfoPolicy(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_ClearAuditLog 
 */
-static NTSTATUS lsa_ClearAuditLog(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_ClearAuditLog(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                  struct lsa_ClearAuditLog *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -657,7 +690,7 @@ static NTSTATUS lsa_ClearAuditLog(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_CreateAccount 
 */
-static NTSTATUS lsa_CreateAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CreateAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                  struct lsa_CreateAccount *r)
 {
        struct lsa_account_state *astate;
@@ -702,7 +735,7 @@ static NTSTATUS lsa_CreateAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_EnumAccounts 
 */
-static NTSTATUS lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                 struct lsa_EnumAccounts *r)
 {
        struct dcesrv_handle *h;
@@ -762,7 +795,7 @@ static NTSTATUS lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /*
   lsa_CreateTrustedDomainEx2
 */
-static NTSTATUS lsa_CreateTrustedDomainEx2(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_CreateTrustedDomainEx2(struct dcesrv_call_state *dce_call,
                                           TALLOC_CTX *mem_ctx,
                                           struct lsa_CreateTrustedDomainEx2 *r)
 {
@@ -772,7 +805,7 @@ static NTSTATUS lsa_CreateTrustedDomainEx2(struct dcesrv_call_state *dce_call,
 /*
   lsa_CreateTrustedDomainEx
 */
-static NTSTATUS lsa_CreateTrustedDomainEx(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_CreateTrustedDomainEx(struct dcesrv_call_state *dce_call,
                                          TALLOC_CTX *mem_ctx,
                                          struct lsa_CreateTrustedDomainEx *r)
 {
@@ -782,7 +815,7 @@ static NTSTATUS lsa_CreateTrustedDomainEx(struct dcesrv_call_state *dce_call,
 /* 
   lsa_CreateTrustedDomain 
 */
-static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                        struct lsa_CreateTrustedDomain *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -833,11 +866,10 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL
        }
        
        msg->dn = ldb_dn_copy(mem_ctx, policy_state->system_dn);
-       if ( ! ldb_dn_add_child_fmt(msg->dn, "sn=%s", r->in.info->name.string)) {
+       if ( ! ldb_dn_add_child_fmt(msg->dn, "cn=%s", name)) {
                return NT_STATUS_NO_MEMORY;
        }
        
-       samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "cn", name);
        samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "flatname", name);
 
        if (r->in.info->sid) {
@@ -879,7 +911,7 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL
 /* 
   lsa_OpenTrustedDomain
 */
-static NTSTATUS lsa_OpenTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_OpenTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                      struct lsa_OpenTrustedDomain *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -946,7 +978,7 @@ static NTSTATUS lsa_OpenTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC
 /*
   lsa_OpenTrustedDomainByName
 */
-static NTSTATUS lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce_call,
                                            TALLOC_CTX *mem_ctx,
                                            struct lsa_OpenTrustedDomainByName *r)
 {
@@ -1013,7 +1045,7 @@ static NTSTATUS lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce_call,
 /* 
   lsa_SetTrustedDomainInfo
 */
-static NTSTATUS lsa_SetTrustedDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetTrustedDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                         struct lsa_SetTrustedDomainInfo *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -1024,7 +1056,7 @@ static NTSTATUS lsa_SetTrustedDomainInfo(struct dcesrv_call_state *dce_call, TAL
 /* 
   lsa_SetInfomrationTrustedDomain
 */
-static NTSTATUS lsa_SetInformationTrustedDomain(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_SetInformationTrustedDomain(struct dcesrv_call_state *dce_call, 
                                                TALLOC_CTX *mem_ctx,
                                                struct lsa_SetInformationTrustedDomain *r)
 {
@@ -1035,7 +1067,7 @@ static NTSTATUS lsa_SetInformationTrustedDomain(struct dcesrv_call_state *dce_ca
 /* 
   lsa_DeleteTrustedDomain
 */
-static NTSTATUS lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                      struct lsa_DeleteTrustedDomain *r)
 {
        NTSTATUS status;
@@ -1050,7 +1082,7 @@ static NTSTATUS lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_call, TALL
        if (!open.out.trustdom_handle) {
                return NT_STATUS_NO_MEMORY;
        }
-       status = lsa_OpenTrustedDomain(dce_call, mem_ctx, &open);
+       status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1059,7 +1091,7 @@ static NTSTATUS lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_call, TALL
        talloc_steal(mem_ctx, h);
 
        delete.in.handle = open.out.trustdom_handle;
-       status = lsa_Delete(dce_call, mem_ctx, &delete);
+       status = dcesrv_lsa_Delete(dce_call, mem_ctx, &delete);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1088,7 +1120,7 @@ static NTSTATUS fill_trust_domain_ex(TALLOC_CTX *mem_ctx,
 /* 
   lsa_QueryTrustedDomainInfo
 */
-static NTSTATUS lsa_QueryTrustedDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                           struct lsa_QueryTrustedDomainInfo *r)
 {
        struct dcesrv_handle *h;
@@ -1170,7 +1202,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfo(struct dcesrv_call_state *dce_call, T
 /* 
   lsa_QueryTrustedDomainInfoBySid
 */
-static NTSTATUS lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                                struct lsa_QueryTrustedDomainInfoBySid *r)
 {
        NTSTATUS status;
@@ -1184,7 +1216,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state *dce_ca
        if (!open.out.trustdom_handle) {
                return NT_STATUS_NO_MEMORY;
        }
-       status = lsa_OpenTrustedDomain(dce_call, mem_ctx, &open);
+       status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1195,7 +1227,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state *dce_ca
        
        query.in.trustdom_handle = open.out.trustdom_handle;
        query.in.level = r->in.level;
-       status = lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query);
+       status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1207,7 +1239,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state *dce_ca
 /*
   lsa_SetTrustedDomainInfoByName
 */
-static NTSTATUS lsa_SetTrustedDomainInfoByName(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_SetTrustedDomainInfoByName(struct dcesrv_call_state *dce_call,
                                               TALLOC_CTX *mem_ctx,
                                               struct lsa_SetTrustedDomainInfoByName *r)
 {
@@ -1217,7 +1249,7 @@ static NTSTATUS lsa_SetTrustedDomainInfoByName(struct dcesrv_call_state *dce_cal
 /* 
    lsa_QueryTrustedDomainInfoByName
 */
-static NTSTATUS lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state *dce_call,
                                                 TALLOC_CTX *mem_ctx,
                                                 struct lsa_QueryTrustedDomainInfoByName *r)
 {
@@ -1232,7 +1264,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state *dce_c
        if (!open.out.trustdom_handle) {
                return NT_STATUS_NO_MEMORY;
        }
-       status = lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &open);
+       status = dcesrv_lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &open);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1243,7 +1275,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state *dce_c
 
        query.in.trustdom_handle = open.out.trustdom_handle;
        query.in.level = r->in.level;
-       status = lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query);
+       status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1255,7 +1287,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state *dce_c
 /*
   lsa_CloseTrustedDomainEx 
 */
-static NTSTATUS lsa_CloseTrustedDomainEx(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_CloseTrustedDomainEx(struct dcesrv_call_state *dce_call,
                                         TALLOC_CTX *mem_ctx,
                                         struct lsa_CloseTrustedDomainEx *r)
 {
@@ -1277,7 +1309,7 @@ static int compare_DomainInfo(struct lsa_DomainInfo *e1, struct lsa_DomainInfo *
 /* 
   lsa_EnumTrustDom 
 */
-static NTSTATUS lsa_EnumTrustDom(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_EnumTrustDom(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                 struct lsa_EnumTrustDom *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -1361,7 +1393,7 @@ static int compare_TrustDomainInfoInfoEx(struct lsa_TrustDomainInfoInfoEx *e1, s
 /* 
   lsa_EnumTrustedDomainsEx 
 */
-static NTSTATUS lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                        struct lsa_EnumTrustedDomainsEx *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -1444,7 +1476,7 @@ static NTSTATUS lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_call, TAL
 /*
   return the authority name and authority sid, given a sid
 */
-static NTSTATUS lsa_authority_name(struct lsa_policy_state *state,
+static NTSTATUS dcesrv_lsa_authority_name(struct lsa_policy_state *state,
                                   TALLOC_CTX *mem_ctx, struct dom_sid *sid,
                                   const char **authority_name,
                                   struct dom_sid **authority_sid)
@@ -1477,7 +1509,7 @@ static NTSTATUS lsa_authority_name(struct lsa_policy_state *state,
 /*
   add to the lsa_RefDomainList for LookupSids and LookupNames
 */
-static NTSTATUS lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx, 
+static NTSTATUS dcesrv_lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx, 
                                   struct dom_sid *sid, 
                                   struct lsa_RefDomainList *domains,
                                   uint32_t *sid_index)
@@ -1488,7 +1520,7 @@ static NTSTATUS lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *m
        int i;
 
        /* work out the authority name */
-       status = lsa_authority_name(state, mem_ctx, sid, 
+       status = dcesrv_lsa_authority_name(state, mem_ctx, sid, 
                                    &authority_name, &authority_sid);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -1521,7 +1553,7 @@ static NTSTATUS lsa_authority_list(struct lsa_policy_state *state, TALLOC_CTX *m
 /*
   lookup a name for 1 SID
 */
-static NTSTATUS lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
                               struct dom_sid *sid, const char *sid_str,
                               const char **name, uint32_t *atype)
 {
@@ -1556,7 +1588,7 @@ static NTSTATUS lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_c
 /*
   lsa_LookupSids2
 */
-static NTSTATUS lsa_LookupSids2(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_LookupSids2(struct dcesrv_call_state *dce_call,
                                TALLOC_CTX *mem_ctx,
                                struct lsa_LookupSids2 *r)
 {
@@ -1566,7 +1598,7 @@ static NTSTATUS lsa_LookupSids2(struct dcesrv_call_state *dce_call,
 
        r->out.domains = NULL;
 
-       status = lsa_get_policy_state(dce_call, mem_ctx, &state);
+       status = dcesrv_lsa_get_policy_state(dce_call, mem_ctx, &state);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1611,12 +1643,12 @@ static NTSTATUS lsa_LookupSids2(struct dcesrv_call_state *dce_call,
                }
 
                /* work out the authority name */
-               status2 = lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
+               status2 = dcesrv_lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
                if (!NT_STATUS_IS_OK(status2)) {
                        return status2;
                }
 
-               status2 = lsa_lookup_sid(state, mem_ctx, sid, sid_str, 
+               status2 = dcesrv_lsa_lookup_sid(state, mem_ctx, sid, sid_str, 
                                         &name, &atype);
                if (!NT_STATUS_IS_OK(status2)) {
                        status = STATUS_SOME_UNMAPPED;
@@ -1645,7 +1677,7 @@ static NTSTATUS lsa_LookupSids2(struct dcesrv_call_state *dce_call,
   Identical to LookupSids2, but doesn't take a policy handle
   
 */
-static NTSTATUS lsa_LookupSids3(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_LookupSids3(struct dcesrv_call_state *dce_call,
                                TALLOC_CTX *mem_ctx,
                                struct lsa_LookupSids3 *r)
 {
@@ -1664,7 +1696,7 @@ static NTSTATUS lsa_LookupSids3(struct dcesrv_call_state *dce_call,
        pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        pol.in.attr = NULL;
        pol.in.system_name = NULL;
-       status = lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
+       status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -1682,7 +1714,7 @@ static NTSTATUS lsa_LookupSids3(struct dcesrv_call_state *dce_call,
        r2.out.count   = r->out.count;
        r2.out.names   = r->out.names;
 
-       status = lsa_LookupSids2(dce_call, mem_ctx, &r2);
+       status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
        if (dce_call->fault_code != 0) {
                return status;
        }
@@ -1698,7 +1730,7 @@ static NTSTATUS lsa_LookupSids3(struct dcesrv_call_state *dce_call,
 /* 
   lsa_LookupSids 
 */
-static NTSTATUS lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                               struct lsa_LookupSids *r)
 {
        struct lsa_LookupSids2 r2;
@@ -1715,7 +1747,7 @@ static NTSTATUS lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
        r2.out.count   = r->out.count;
        r2.out.names   = NULL;
 
-       status = lsa_LookupSids2(dce_call, mem_ctx, &r2);
+       status = dcesrv_lsa_LookupSids2(dce_call, mem_ctx, &r2);
        if (dce_call->fault_code != 0) {
                return status;
        }
@@ -1749,7 +1781,7 @@ static NTSTATUS lsa_LookupSids(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
 /* 
   lsa_OpenAccount 
 */
-static NTSTATUS lsa_OpenAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_OpenAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                struct lsa_OpenAccount *r)
 {
        struct dcesrv_handle *h, *ah;
@@ -1793,7 +1825,7 @@ static NTSTATUS lsa_OpenAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /* 
   lsa_EnumPrivsAccount 
 */
-static NTSTATUS lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call, 
                                     TALLOC_CTX *mem_ctx,
                                     struct lsa_EnumPrivsAccount *r)
 {
@@ -1854,7 +1886,7 @@ static NTSTATUS lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call,
 /* 
   lsa_EnumAccountRights 
 */
-static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, 
                                      TALLOC_CTX *mem_ctx,
                                      struct lsa_EnumAccountRights *r)
 {
@@ -1914,7 +1946,7 @@ static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call,
 /* 
   helper for lsa_AddAccountRights and lsa_RemoveAccountRights
 */
-static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call, 
                                           TALLOC_CTX *mem_ctx,
                                           struct lsa_policy_state *state,
                                           int ldb_flag,
@@ -1963,7 +1995,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
                r2.in.sid = sid;
                r2.out.rights = talloc(mem_ctx, struct lsa_RightSet);
 
-               status = lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
+               status = dcesrv_lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
                if (!NT_STATUS_IS_OK(status)) {
                        ZERO_STRUCTP(r2.out.rights);
                }
@@ -2013,7 +2045,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
 /* 
   lsa_AddPrivilegesToAccount
 */
-static NTSTATUS lsa_AddPrivilegesToAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_AddPrivilegesToAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                           struct lsa_AddPrivilegesToAccount *r)
 {
        struct lsa_RightSet rights;
@@ -2041,7 +2073,7 @@ static NTSTATUS lsa_AddPrivilegesToAccount(struct dcesrv_call_state *dce_call, T
                }
        }
 
-       return lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
+       return dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
                                          LDB_FLAG_MOD_ADD, astate->account_sid,
                                          &rights);
 }
@@ -2050,7 +2082,7 @@ static NTSTATUS lsa_AddPrivilegesToAccount(struct dcesrv_call_state *dce_call, T
 /* 
   lsa_RemovePrivilegesFromAccount
 */
-static NTSTATUS lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                                struct lsa_RemovePrivilegesFromAccount *r)
 {
        struct lsa_RightSet *rights;
@@ -2073,12 +2105,12 @@ static NTSTATUS lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state *dce_ca
                r2.in.sid = astate->account_sid;
                r2.out.rights = rights;
 
-               status = lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
+               status = dcesrv_lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
 
-               return lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
+               return dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
                                                  LDB_FLAG_MOD_DELETE, astate->account_sid,
                                                  r2.out.rights);
        }
@@ -2103,7 +2135,7 @@ static NTSTATUS lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state *dce_ca
                }
        }
 
-       return lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
+       return dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, astate->policy, 
                                          LDB_FLAG_MOD_DELETE, astate->account_sid,
                                          rights);
 }
@@ -2112,7 +2144,7 @@ static NTSTATUS lsa_RemovePrivilegesFromAccount(struct dcesrv_call_state *dce_ca
 /* 
   lsa_GetQuotasForAccount
 */
-static NTSTATUS lsa_GetQuotasForAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_GetQuotasForAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_GetQuotasForAccount *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2122,7 +2154,7 @@ static NTSTATUS lsa_GetQuotasForAccount(struct dcesrv_call_state *dce_call, TALL
 /* 
   lsa_SetQuotasForAccount
 */
-static NTSTATUS lsa_SetQuotasForAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetQuotasForAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_SetQuotasForAccount *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2132,7 +2164,7 @@ static NTSTATUS lsa_SetQuotasForAccount(struct dcesrv_call_state *dce_call, TALL
 /* 
   lsa_GetSystemAccessAccount
 */
-static NTSTATUS lsa_GetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_GetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_GetSystemAccessAccount *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2142,7 +2174,7 @@ static NTSTATUS lsa_GetSystemAccessAccount(struct dcesrv_call_state *dce_call, T
 /* 
   lsa_SetSystemAccessAccount
 */
-static NTSTATUS lsa_SetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetSystemAccessAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_SetSystemAccessAccount *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2152,7 +2184,7 @@ static NTSTATUS lsa_SetSystemAccessAccount(struct dcesrv_call_state *dce_call, T
 /* 
   lsa_CreateSecret 
 */
-static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                 struct lsa_CreateSecret *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -2253,7 +2285,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
 
        /* pull in all the template attributes.  Note this is always from the global samdb */
        ret = samdb_copy_template(secret_state->policy->sam_ldb, msg, 
-                                 "(&(cn=TemplateSecret)(objectclass=secretTemplate))", &errstr);
+                                 "secret", &errstr);
        if (ret != 0) {
                DEBUG(0,("Failed to load TemplateSecret from samdb: %s\n",
                         errstr));
@@ -2270,7 +2302,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
                DEBUG(0,("Failed to create secret record %s: %s\n",
                         ldb_dn_get_linearized(msg->dn), 
                         ldb_errstring(secret_state->sam_ldb)));
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
+               return NT_STATUS_ACCESS_DENIED;
        }
 
        handle = dcesrv_handle_new(dce_call->context, LSA_HANDLE_SECRET);
@@ -2292,7 +2324,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_OpenSecret 
 */
-static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                               struct lsa_OpenSecret *r)
 {
        struct dcesrv_handle *policy_handle;
@@ -2367,8 +2399,8 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
                }
                
                if (ret != 1) {
-                       DEBUG(0,("Found %d records matching DN %s\n", ret,
-                                ldb_dn_get_linearized(policy_state->system_dn)));
+                       DEBUG(0,("Found %d records matching CN=%s\n", 
+                                ret, ldb_binary_encode_string(mem_ctx, name)));
                        return NT_STATUS_INTERNAL_DB_CORRUPTION;
                }
        } 
@@ -2394,7 +2426,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
 /* 
   lsa_SetSecret 
 */
-static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                              struct lsa_SetSecret *r)
 {
 
@@ -2560,7 +2592,7 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 /* 
   lsa_QuerySecret 
 */
-static NTSTATUS lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                struct lsa_QuerySecret *r)
 {
        struct dcesrv_handle *h;
@@ -2675,7 +2707,7 @@ static NTSTATUS lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /* 
   lsa_LookupPrivValue
 */
-static NTSTATUS lsa_LookupPrivValue(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_LookupPrivValue(struct dcesrv_call_state *dce_call, 
                                    TALLOC_CTX *mem_ctx,
                                    struct lsa_LookupPrivValue *r)
 {
@@ -2702,7 +2734,7 @@ static NTSTATUS lsa_LookupPrivValue(struct dcesrv_call_state *dce_call,
 /* 
   lsa_LookupPrivName 
 */
-static NTSTATUS lsa_LookupPrivName(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_LookupPrivName(struct dcesrv_call_state *dce_call, 
                                   TALLOC_CTX *mem_ctx,
                                   struct lsa_LookupPrivName *r)
 {
@@ -2736,7 +2768,7 @@ static NTSTATUS lsa_LookupPrivName(struct dcesrv_call_state *dce_call,
 /* 
   lsa_LookupPrivDisplayName
 */
-static NTSTATUS lsa_LookupPrivDisplayName(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_LookupPrivDisplayName(struct dcesrv_call_state *dce_call, 
                                          TALLOC_CTX *mem_ctx,
                                          struct lsa_LookupPrivDisplayName *r)
 {
@@ -2770,7 +2802,7 @@ static NTSTATUS lsa_LookupPrivDisplayName(struct dcesrv_call_state *dce_call,
 /* 
   lsa_DeleteObject
 */
-static NTSTATUS lsa_DeleteObject(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_DeleteObject(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_DeleteObject *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2780,7 +2812,7 @@ static NTSTATUS lsa_DeleteObject(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /* 
   lsa_EnumAccountsWithUserRight
 */
-static NTSTATUS lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *dce_call, 
                                              TALLOC_CTX *mem_ctx,
                                              struct lsa_EnumAccountsWithUserRight *r)
 {
@@ -2831,7 +2863,7 @@ static NTSTATUS lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *dce_call
 /* 
   lsa_AddAccountRights
 */
-static NTSTATUS lsa_AddAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_AddAccountRights(struct dcesrv_call_state *dce_call, 
                                     TALLOC_CTX *mem_ctx,
                                     struct lsa_AddAccountRights *r)
 {
@@ -2842,7 +2874,7 @@ static NTSTATUS lsa_AddAccountRights(struct dcesrv_call_state *dce_call,
 
        state = h->data;
 
-       return lsa_AddRemoveAccountRights(dce_call, mem_ctx, state, 
+       return dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, state, 
                                          LDB_FLAG_MOD_ADD,
                                          r->in.sid, r->in.rights);
 }
@@ -2851,7 +2883,7 @@ static NTSTATUS lsa_AddAccountRights(struct dcesrv_call_state *dce_call,
 /* 
   lsa_RemoveAccountRights
 */
-static NTSTATUS lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call, 
+static NTSTATUS dcesrv_lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call, 
                                        TALLOC_CTX *mem_ctx,
                                        struct lsa_RemoveAccountRights *r)
 {
@@ -2862,7 +2894,7 @@ static NTSTATUS lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call,
 
        state = h->data;
 
-       return lsa_AddRemoveAccountRights(dce_call, mem_ctx, state, 
+       return dcesrv_lsa_AddRemoveAccountRights(dce_call, mem_ctx, state, 
                                          LDB_FLAG_MOD_DELETE,
                                          r->in.sid, r->in.rights);
 }
@@ -2871,7 +2903,7 @@ static NTSTATUS lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call,
 /* 
   lsa_StorePrivateData
 */
-static NTSTATUS lsa_StorePrivateData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_StorePrivateData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_StorePrivateData *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2881,7 +2913,7 @@ static NTSTATUS lsa_StorePrivateData(struct dcesrv_call_state *dce_call, TALLOC_
 /* 
   lsa_RetrievePrivateData
 */
-static NTSTATUS lsa_RetrievePrivateData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_RetrievePrivateData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_RetrievePrivateData *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -2891,7 +2923,7 @@ static NTSTATUS lsa_RetrievePrivateData(struct dcesrv_call_state *dce_call, TALL
 /* 
   lsa_GetUserName
 */
-static NTSTATUS lsa_GetUserName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_GetUserName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                struct lsa_GetUserName *r)
 {
        NTSTATUS status = NT_STATUS_OK;
@@ -2938,7 +2970,7 @@ static NTSTATUS lsa_GetUserName(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /*
   lsa_SetInfoPolicy2
 */
-static NTSTATUS lsa_SetInfoPolicy2(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_SetInfoPolicy2(struct dcesrv_call_state *dce_call,
                                   TALLOC_CTX *mem_ctx,
                                   struct lsa_SetInfoPolicy2 *r)
 {
@@ -2948,7 +2980,7 @@ static NTSTATUS lsa_SetInfoPolicy2(struct dcesrv_call_state *dce_call,
 /*
   lsa_QueryDomainInformationPolicy
 */
-static NTSTATUS lsa_QueryDomainInformationPolicy(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_QueryDomainInformationPolicy(struct dcesrv_call_state *dce_call,
                                                 TALLOC_CTX *mem_ctx,
                                                 struct lsa_QueryDomainInformationPolicy *r)
 {
@@ -2958,7 +2990,7 @@ static NTSTATUS lsa_QueryDomainInformationPolicy(struct dcesrv_call_state *dce_c
 /*
   lsa_SetDomInfoPolicy
 */
-static NTSTATUS lsa_SetDomainInformationPolicy(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_SetDomainInformationPolicy(struct dcesrv_call_state *dce_call,
                                              TALLOC_CTX *mem_ctx,
                                              struct lsa_SetDomainInformationPolicy *r)
 {
@@ -2968,7 +3000,7 @@ static NTSTATUS lsa_SetDomainInformationPolicy(struct dcesrv_call_state *dce_cal
 /*
   lsa_TestCall
 */
-static NTSTATUS lsa_TestCall(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_TestCall(struct dcesrv_call_state *dce_call,
                             TALLOC_CTX *mem_ctx,
                             struct lsa_TestCall *r)
 {
@@ -2978,7 +3010,7 @@ static NTSTATUS lsa_TestCall(struct dcesrv_call_state *dce_call,
 /*
   lookup a SID for 1 name
 */
-static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
                                const char *name, struct dom_sid **sid, uint32_t *atype)
 {
        int ret;
@@ -3014,7 +3046,7 @@ static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_
 /*
   lsa_LookupNames3
 */
-static NTSTATUS lsa_LookupNames3(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call,
                                 TALLOC_CTX *mem_ctx,
                                 struct lsa_LookupNames3 *r)
 {
@@ -3061,7 +3093,7 @@ static NTSTATUS lsa_LookupNames3(struct dcesrv_call_state *dce_call,
                r->out.sids->sids[i].sid_index   = 0xFFFFFFFF;
                r->out.sids->sids[i].unknown     = 0;
 
-               status2 = lsa_lookup_name(policy_state, mem_ctx, name, &sid, &atype);
+               status2 = dcesrv_lsa_lookup_name(policy_state, mem_ctx, name, &sid, &atype);
                if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
                        status = STATUS_SOME_UNMAPPED;
                        continue;
@@ -3073,7 +3105,7 @@ static NTSTATUS lsa_LookupNames3(struct dcesrv_call_state *dce_call,
                        continue;
                }
 
-               status2 = lsa_authority_list(policy_state, mem_ctx, sid, r->out.domains, &sid_index);
+               status2 = dcesrv_lsa_authority_list(policy_state, mem_ctx, sid, r->out.domains, &sid_index);
                if (!NT_STATUS_IS_OK(status2)) {
                        return status2;
                }
@@ -3093,7 +3125,7 @@ static NTSTATUS lsa_LookupNames3(struct dcesrv_call_state *dce_call,
   Identical to LookupNames3, but doesn't take a policy handle
   
 */
-static NTSTATUS lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                 struct lsa_LookupNames4 *r)
 {
        struct lsa_LookupNames3 r2;
@@ -3111,7 +3143,7 @@ static NTSTATUS lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX
        pol.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        pol.in.attr = NULL;
        pol.in.system_name = NULL;
-       status = lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
+       status = dcesrv_lsa_OpenPolicy2(dce_call, mem_ctx, &pol);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -3130,7 +3162,7 @@ static NTSTATUS lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX
        r2.out.sids = r->out.sids;
        r2.out.count = r->out.count;
        
-       status = lsa_LookupNames3(dce_call, mem_ctx, &r2);
+       status = dcesrv_lsa_LookupNames3(dce_call, mem_ctx, &r2);
        if (dce_call->fault_code != 0) {
                return status;
        }
@@ -3144,7 +3176,7 @@ static NTSTATUS lsa_LookupNames4(struct dcesrv_call_state *dce_call, TALLOC_CTX
 /*
   lsa_LookupNames2
 */
-static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
+static NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call,
                                 TALLOC_CTX *mem_ctx,
                                 struct lsa_LookupNames2 *r)
 {
@@ -3191,7 +3223,7 @@ static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
                r->out.sids->sids[i].sid_index   = 0xFFFFFFFF;
                r->out.sids->sids[i].unknown     = 0;
 
-               status2 = lsa_lookup_name(state, mem_ctx, name, &sid, &atype);
+               status2 = dcesrv_lsa_lookup_name(state, mem_ctx, name, &sid, &atype);
                if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
                        status = STATUS_SOME_UNMAPPED;
                        continue;
@@ -3203,7 +3235,7 @@ static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
                        continue;
                }
 
-               status2 = lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
+               status2 = dcesrv_lsa_authority_list(state, mem_ctx, sid, r->out.domains, &sid_index);
                if (!NT_STATUS_IS_OK(status2)) {
                        return status2;
                }
@@ -3220,7 +3252,7 @@ static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
 /* 
   lsa_LookupNames 
 */
-static NTSTATUS lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LookupNames *r)
 {
        struct lsa_LookupNames2 r2;
@@ -3237,7 +3269,7 @@ static NTSTATUS lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *
        r2.in.unknown2  = 0;
        r2.out.count    = r->out.count;
 
-       status = lsa_LookupNames2(dce_call, mem_ctx, &r2);
+       status = dcesrv_lsa_LookupNames2(dce_call, mem_ctx, &r2);
        if (dce_call->fault_code != 0) {
                return status;
        }
@@ -3265,7 +3297,7 @@ static NTSTATUS lsa_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /* 
   lsa_CREDRWRITE 
 */
-static NTSTATUS lsa_CREDRWRITE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRWRITE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRWRITE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3275,7 +3307,7 @@ static NTSTATUS lsa_CREDRWRITE(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
 /* 
   lsa_CREDRREAD 
 */
-static NTSTATUS lsa_CREDRREAD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRREAD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRREAD *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3285,7 +3317,7 @@ static NTSTATUS lsa_CREDRREAD(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
 /* 
   lsa_CREDRENUMERATE 
 */
-static NTSTATUS lsa_CREDRENUMERATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRENUMERATE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRENUMERATE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3295,7 +3327,7 @@ static NTSTATUS lsa_CREDRENUMERATE(struct dcesrv_call_state *dce_call, TALLOC_CT
 /* 
   lsa_CREDRWRITEDOMAINCREDENTIALS 
 */
-static NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRWRITEDOMAINCREDENTIALS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRWRITEDOMAINCREDENTIALS *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3305,7 +3337,7 @@ static NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS(struct dcesrv_call_state *dce_ca
 /* 
   lsa_CREDRREADDOMAINCREDENTIALS 
 */
-static NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRREADDOMAINCREDENTIALS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRREADDOMAINCREDENTIALS *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3315,7 +3347,7 @@ static NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS(struct dcesrv_call_state *dce_cal
 /* 
   lsa_CREDRDELETE 
 */
-static NTSTATUS lsa_CREDRDELETE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRDELETE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRDELETE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3325,7 +3357,7 @@ static NTSTATUS lsa_CREDRDELETE(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /* 
   lsa_CREDRGETTARGETINFO 
 */
-static NTSTATUS lsa_CREDRGETTARGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRGETTARGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRGETTARGETINFO *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3335,7 +3367,7 @@ static NTSTATUS lsa_CREDRGETTARGETINFO(struct dcesrv_call_state *dce_call, TALLO
 /* 
   lsa_CREDRPROFILELOADED 
 */
-static NTSTATUS lsa_CREDRPROFILELOADED(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRPROFILELOADED(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRPROFILELOADED *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3345,7 +3377,7 @@ static NTSTATUS lsa_CREDRPROFILELOADED(struct dcesrv_call_state *dce_call, TALLO
 /* 
   lsa_CREDRGETSESSIONTYPES 
 */
-static NTSTATUS lsa_CREDRGETSESSIONTYPES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRGETSESSIONTYPES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRGETSESSIONTYPES *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3355,7 +3387,7 @@ static NTSTATUS lsa_CREDRGETSESSIONTYPES(struct dcesrv_call_state *dce_call, TAL
 /* 
   lsa_LSARREGISTERAUDITEVENT 
 */
-static NTSTATUS lsa_LSARREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARREGISTERAUDITEVENT *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3365,7 +3397,7 @@ static NTSTATUS lsa_LSARREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call, T
 /* 
   lsa_LSARGENAUDITEVENT 
 */
-static NTSTATUS lsa_LSARGENAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARGENAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARGENAUDITEVENT *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3375,7 +3407,7 @@ static NTSTATUS lsa_LSARGENAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC
 /* 
   lsa_LSARUNREGISTERAUDITEVENT 
 */
-static NTSTATUS lsa_LSARUNREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARUNREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARUNREGISTERAUDITEVENT *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3383,10 +3415,10 @@ static NTSTATUS lsa_LSARUNREGISTERAUDITEVENT(struct dcesrv_call_state *dce_call,
 
 
 /* 
-  lsa_LSARQUERYFORESTTRUSTINFORMATION 
+  lsa_lsaRQueryForestTrustInformation 
 */
-static NTSTATUS lsa_LSARQUERYFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
-                      struct lsa_LSARQUERYFORESTTRUSTINFORMATION *r)
+static NTSTATUS dcesrv_lsa_lsaRQueryForestTrustInformation(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+                      struct lsa_lsaRQueryForestTrustInformation *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
 }
@@ -3395,7 +3427,7 @@ static NTSTATUS lsa_LSARQUERYFORESTTRUSTINFORMATION(struct dcesrv_call_state *dc
 /* 
   lsa_LSARSETFORESTTRUSTINFORMATION 
 */
-static NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARSETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARSETFORESTTRUSTINFORMATION *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3405,7 +3437,7 @@ static NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION(struct dcesrv_call_state *dce_
 /* 
   lsa_CREDRRENAME 
 */
-static NTSTATUS lsa_CREDRRENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_CREDRRENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_CREDRRENAME *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3416,7 +3448,7 @@ static NTSTATUS lsa_CREDRRENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *
 /* 
   lsa_LSAROPENPOLICYSCE 
 */
-static NTSTATUS lsa_LSAROPENPOLICYSCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSAROPENPOLICYSCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSAROPENPOLICYSCE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3426,7 +3458,7 @@ static NTSTATUS lsa_LSAROPENPOLICYSCE(struct dcesrv_call_state *dce_call, TALLOC
 /* 
   lsa_LSARADTREGISTERSECURITYEVENTSOURCE 
 */
-static NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3436,7 +3468,7 @@ static NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_state
 /* 
   lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE 
 */
-static NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3446,7 +3478,7 @@ static NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(struct dcesrv_call_stat
 /* 
   lsa_LSARADTREPORTSECURITYEVENT 
 */
-static NTSTATUS lsa_LSARADTREPORTSECURITYEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static NTSTATUS dcesrv_lsa_LSARADTREPORTSECURITYEVENT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct lsa_LSARADTREPORTSECURITYEVENT *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3468,7 +3500,7 @@ not try and fill these in with anything else
 /* 
   dssetup_DsRoleDnsNameToFlatName 
 */
-static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                        struct dssetup_DsRoleDnsNameToFlatName *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3478,7 +3510,7 @@ static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call
 /* 
   dssetup_DsRoleDcAsDc 
 */
-static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                             struct dssetup_DsRoleDcAsDc *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3488,7 +3520,7 @@ static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CT
 /* 
   dssetup_DsRoleDcAsReplica 
 */
-static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                  struct dssetup_DsRoleDcAsReplica *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3498,7 +3530,7 @@ static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALL
 /* 
   dssetup_DsRoleDemoteDc 
 */
-static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                               struct dssetup_DsRoleDemoteDc *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3508,7 +3540,7 @@ static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_
 /* 
   dssetup_DsRoleGetDcOperationProgress 
 */
-static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                             struct dssetup_DsRoleGetDcOperationProgress *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3518,7 +3550,7 @@ static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce
 /* 
   dssetup_DsRoleGetDcOperationResults 
 */
-static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                            struct dssetup_DsRoleGetDcOperationResults *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3528,7 +3560,7 @@ static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_
 /* 
   dssetup_DsRoleCancel 
 */
-static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                             struct dssetup_DsRoleCancel *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3538,7 +3570,7 @@ static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CT
 /* 
   dssetup_DsRoleServerSaveStateForUpgrade 
 */
-static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                                struct dssetup_DsRoleServerSaveStateForUpgrade *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3548,7 +3580,7 @@ static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *
 /* 
   dssetup_DsRoleUpgradeDownlevelServer 
 */
-static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                             struct dssetup_DsRoleUpgradeDownlevelServer *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
@@ -3558,7 +3590,7 @@ static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce
 /* 
   dssetup_DsRoleAbortDownlevelServerUpgrade 
 */
-static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+static WERROR dcesrv_dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                                  struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
 {
        DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);