Skip to content

Commit b09eed6

Browse files
added handler to interface with ldap search
1 parent 33ee6ec commit b09eed6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/search/handlers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package search
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"encoding/json"
7+
)
8+
9+
/* handler to return list of all users in LDAP server */
10+
func SearchUsersHandler(w http.ResponseWriter, r *http.Request) {
11+
/* fetch all users from LDAP server */
12+
users, err := GetAllUsersFromLDAP()
13+
if err != nil {
14+
http.Error(w, fmt.Sprintf("LDAP error: %v", err), http.StatusInternalServerError)
15+
return
16+
}
17+
18+
w.Header().Set("Content-Type", "application/json")
19+
json.NewEncoder(w).Encode(users)
20+
}

0 commit comments

Comments
 (0)