diff --git a/object/ldap.go b/object/ldap.go
index 624f41e1..5122dd07 100644
--- a/object/ldap.go
+++ b/object/ldap.go
@@ -32,6 +32,7 @@ type Ldap struct {
BaseDn string `xorm:"varchar(100)" json:"baseDn"`
Filter string `xorm:"varchar(200)" json:"filter"`
FilterFields []string `xorm:"varchar(100)" json:"filterFields"`
+ DefaultGroup string `xorm:"varchar(100)" json:"defaultGroup"`
AutoSync int `json:"autoSync"`
LastSync string `xorm:"varchar(100)" json:"lastSync"`
@@ -148,7 +149,7 @@ func UpdateLdap(ldap *Ldap) (bool, error) {
}
affected, err := ormer.Engine.ID(ldap.Id).Cols("owner", "server_name", "host",
- "port", "enable_ssl", "username", "password", "base_dn", "filter", "filter_fields", "auto_sync").Update(ldap)
+ "port", "enable_ssl", "username", "password", "base_dn", "filter", "filter_fields", "auto_sync", "default_group").Update(ldap)
if err != nil {
return false, nil
}
diff --git a/object/ldap_conn.go b/object/ldap_conn.go
index 34be1d4d..47fc94e4 100644
--- a/object/ldap_conn.go
+++ b/object/ldap_conn.go
@@ -339,6 +339,10 @@ func SyncLdapUsers(owner string, syncUsers []LdapUser, ldapId string) (existUser
Ldap: syncUser.Uuid,
}
+ if ldap.DefaultGroup != "" {
+ newUser.Groups = []string{ldap.DefaultGroup}
+ }
+
affected, err := AddUser(newUser)
if err != nil {
return nil, nil, err
diff --git a/web/src/LdapEditPage.js b/web/src/LdapEditPage.js
index 88b6d4c0..df38d3fb 100644
--- a/web/src/LdapEditPage.js
+++ b/web/src/LdapEditPage.js
@@ -13,12 +13,13 @@
// limitations under the License.
import React from "react";
-import {Button, Card, Col, Input, InputNumber, Row, Select, Switch} from "antd";
-import {EyeInvisibleOutlined, EyeTwoTone} from "@ant-design/icons";
+import {Button, Card, Col, Input, InputNumber, Row, Select, Space, Switch} from "antd";
+import {EyeInvisibleOutlined, EyeTwoTone, HolderOutlined, UsergroupAddOutlined} from "@ant-design/icons";
import * as LddpBackend from "./backend/LdapBackend";
import * as OrganizationBackend from "./backend/OrganizationBackend";
import * as Setting from "./Setting";
import i18next from "i18next";
+import * as GroupBackend from "./backend/GroupBackend";
const {Option} = Select;
@@ -30,12 +31,14 @@ class LdapEditPage extends React.Component {
organizationName: props.match.params.organizationName,
ldap: null,
organizations: [],
+ groups: null,
};
}
UNSAFE_componentWillMount() {
this.getLdap();
this.getOrganizations();
+ this.getGroups();
}
getLdap() {
@@ -60,6 +63,17 @@ class LdapEditPage extends React.Component {
});
}
+ getGroups() {
+ GroupBackend.getGroups(this.state.organizationName)
+ .then((res) => {
+ if (res.status === "ok") {
+ this.setState({
+ groups: res.data,
+ });
+ }
+ });
+ }
+
updateLdapField(key, value) {
this.setState((prevState) => {
prevState.ldap[key] = value;
@@ -214,6 +228,31 @@ class LdapEditPage extends React.Component {
/>
+
+
+ {Setting.getLabel(i18next.t("ldap:Default group"), i18next.t("ldap:Default group - Tooltip"))} :
+
+
+
+
+
{Setting.getLabel(i18next.t("ldap:Auto Sync"), i18next.t("ldap:Auto Sync - Tooltip"))} :