summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/param/loadparm.h1
-rw-r--r--lib/param/loadparm_server_role.c39
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h
index ecf8f9c6a8..a50384d873 100644
--- a/lib/param/loadparm.h
+++ b/lib/param/loadparm.h
@@ -136,3 +136,4 @@ struct parm_struct {
const char* server_role_str(uint32_t role);
int lp_find_server_role(int server_role, int security, bool domain_logons, bool domain_master);
int lp_find_security(int server_role, int security);
+bool lp_is_security_and_server_role_valid(int server_role, int security);
diff --git a/lib/param/loadparm_server_role.c b/lib/param/loadparm_server_role.c
index d80ee7e876..a39d5fa214 100644
--- a/lib/param/loadparm_server_role.c
+++ b/lib/param/loadparm_server_role.c
@@ -141,3 +141,42 @@ int lp_find_security(int server_role, int security)
return SEC_USER;
}
}
+
+
+/**
+ * Check if server role and security parameters are contradictory
+ */
+bool lp_is_security_and_server_role_valid(int server_role, int security)
+{
+ bool valid = false;
+
+ if (server_role == ROLE_AUTO || security == SEC_AUTO) {
+ return false;
+ }
+
+ switch (server_role) {
+ case ROLE_STANDALONE:
+ if (security == SEC_SHARE || security == SEC_SERVER || security == SEC_USER) {
+ valid = true;
+ }
+ break;
+
+ case ROLE_DOMAIN_MEMBER:
+ if (security == SEC_ADS || security == SEC_DOMAIN) {
+ valid = true;
+ }
+ break;
+
+ case ROLE_DOMAIN_PDC:
+ case ROLE_DOMAIN_BDC:
+ if (security == SEC_USER) {
+ valid = true;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return valid;
+}