diff --git a/pkg/util/ldap/ldap_client.go b/pkg/util/ldap/ldap_client.go
index 7d682507..b3076cfe 100644
--- a/pkg/util/ldap/ldap_client.go
+++ b/pkg/util/ldap/ldap_client.go
@@ -47,11 +47,11 @@ func (l *Ldap) Connect() error {
func (l *Ldap) Search(dn, filter string, sizeLimit, timeLimit int, attributes []string) ([]*ldap.Entry, error) {
searchRequest := ldap.NewSearchRequest(dn,
- ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, sizeLimit, timeLimit, false,
+ ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, timeLimit, false,
filter,
attributes,
nil)
- sr, err := l.Conn.Search(searchRequest)
+ sr, err := l.Conn.SearchWithPaging(searchRequest, uint32(sizeLimit))
if err != nil {
return nil, err
}
@@ -81,5 +81,6 @@ func (l *Ldap) Login(dn, filter, password string, sizeLimit, timeLimit int) erro
return err
}
defer l.Conn.Close()
+
return nil
}
diff --git a/pkg/util/ldap/ldap_client_test.go b/pkg/util/ldap/ldap_client_test.go
new file mode 100644
index 00000000..746212a7
--- /dev/null
+++ b/pkg/util/ldap/ldap_client_test.go
@@ -0,0 +1,32 @@
+package ldap
+
+import (
+ "fmt"
+ "github.com/go-ldap/ldap/v3"
+ "testing"
+)
+
+func TestLdapClient(t *testing.T) {
+
+ client := NewLdapClient("172.16.10.89", "389", "CN=zhengkun2,CN=Users,DC=ko,DC=com", "Calong@2015", false)
+ err := client.Connect()
+ if err != nil {
+ fmt.Println(err.Error())
+ return
+ }
+ for i := 1; i < 1200; i++ {
+ username := fmt.Sprintf("kubepi%d", i)
+ email := username + "@fit2cloud.com"
+ userdn := "CN=" + username + ",CN=Users,DC=ko,DC=com"
+ add := ldap.NewAddRequest(userdn, nil)
+ add.Attribute("objectClass", []string{"top", "person", "organizationalPerson", "user"})
+ add.Attribute("cn", []string{username})
+ add.Attribute("sAMAccountName", []string{username})
+ add.Attribute("mail", []string{email})
+ err = client.Conn.Add(add)
+ if err != nil {
+ fmt.Println(err.Error())
+ return
+ }
+ }
+}
diff --git a/web/kubepi/src/business/user-management/ldap/index.vue b/web/kubepi/src/business/user-management/ldap/index.vue
index 095f41cb..520faab5 100644
--- a/web/kubepi/src/business/user-management/ldap/index.vue
+++ b/web/kubepi/src/business/user-management/ldap/index.vue
@@ -43,7 +43,7 @@
- {{ $t('commons.enable.true') }}
+ {{ $t("commons.enable.true") }}
@@ -67,10 +67,10 @@
$t("business.user.ldap_remake")
}}
-
-
-
-
+
+
+
+
{{ $t("commons.button.confirm") }}
@@ -103,8 +103,14 @@
-
-
+
+
+
+
+
@@ -117,17 +123,21 @@
{{ row.available ? $t("commons.bool.true") : $t("commons.bool.false") }}
-
-
-
-
- {{ $t("commons.button.cancel") }}
-
- {{ $t("commons.button.confirm") }}
-
-
+
+
+
+
+
+ {{ $t("commons.button.cancel") }}
+
+ {{ $t("commons.button.confirm") }}
+
@@ -144,7 +154,7 @@ import ComplexTable from "@/components/complex-table"
export default {
name: "LDAP",
- components: { ComplexTable,LayoutContent },
+ components: { ComplexTable, LayoutContent },
props: {},
data () {
return {
@@ -187,7 +197,13 @@ export default {
importUserPageOpen: false,
importLoading: false,
connectLoading: false,
- oldConfig: {}
+ oldConfig: {},
+ pageConfig: {
+ currentPage: 1,
+ pageSize: 10,
+ },
+ tableUsers: [],
+ searchName: ""
}
},
methods: {
@@ -219,14 +235,18 @@ export default {
if (!isFormReady) {
return
}
+ this.tableUsers = []
+ this.loading = true
this.connectLoading = true
testConnect(this.form).then(res => {
this.users = res.data
+ this.tableUsers = this.users
this.$message({
type: "success",
message: this.$t("business.user.test_result", { count: res.data.length })
})
}).finally(() => {
+ this.loading = false
this.connectLoading = false
})
},
@@ -236,15 +256,17 @@ export default {
},
openImportPage () {
this.importUserPageOpen = true
+ this.searchName = ""
if (this.users.length === 0) {
this.connectTest()
}
+ this.tableUsers = this.users
},
- importAvailable(row) {
+ importAvailable (row) {
return row.available
},
- remake(){
- this.form = JSON.parse(JSON.stringify( this.oldConfig))
+ remake () {
+ this.form = JSON.parse(JSON.stringify(this.oldConfig))
},
loginTest () {
let isFormReady = false
@@ -256,6 +278,7 @@ export default {
if (!isFormReady) {
return
}
+ this.loginLoading = true
testLogin(this.loginForm).then(() => {
this.$message({
type: "success",
@@ -265,12 +288,12 @@ export default {
this.loginLoading = false
})
},
- userImport(){
+ userImport () {
if (this.selects.length === 0) {
return
}
let req = {
- users : this.selects
+ users: this.selects
}
this.importLoading = true
importUser(req).then(res => {
@@ -280,10 +303,10 @@ export default {
message: this.$t("business.user.import_user_success")
})
this.importUserPageOpen = false
- }else {
+ } else {
this.$message({
type: "failed",
- message: this.$t("business.user.import_user_failed",{user:res.failures})
+ message: this.$t("business.user.import_user_failed", { user: res.failures })
})
}
}).finally(() => {
@@ -335,11 +358,19 @@ export default {
getLdap().then((res) => {
if (res.data.length > 0) {
this.form = res.data[0]
- this.oldConfig = res.data[0]
+ this.oldConfig = res.data[0]
}
}).finally(() => {
this.loading = false
})
+ },
+ handleSelectionChange(val) {
+ this.selects = val
+ },
+ handleSearch(){
+ this.tableUsers =this.users.filter(user => {
+ return user.name.indexOf(this.searchName) > -1
+ })
}
},
created () {