BUGFIX : Order of checks (result before result.Attributes...)
This commit is contained in:
+10
-10
@@ -43,7 +43,6 @@ var (
|
|||||||
defDomain *string
|
defDomain *string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func ldapSearch(conLdap *ldap.Conn, searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
func ldapSearch(conLdap *ldap.Conn, searchReq *ldap.SearchRequest, attempt int) (*ldap.SearchResult, error) {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
result, err := conLdap.Search(searchReq)
|
result, err := conLdap.Search(searchReq)
|
||||||
@@ -64,7 +63,6 @@ func ldapSearch(conLdap *ldap.Conn, searchReq *ldap.SearchRequest, attempt int)
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
|
func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
|
||||||
var s string
|
var s string
|
||||||
var mxdom string
|
var mxdom string
|
||||||
@@ -120,14 +118,6 @@ func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// L'attribut n'existe pas
|
|
||||||
if len(result.Entries[0].Attributes) == 0 {
|
|
||||||
logstream.Err(fmt.Sprintf("Error searching into LDAP: Attribute %s not found for entry %s\n", *ldapAttr, result.Entries[0]))
|
|
||||||
s := strings.Replace(fmt.Sprintf("Attribute not found: %s", *ldapAttr), " ", "%20", -1)
|
|
||||||
response := fmt.Sprintf("500 %s\n", s)
|
|
||||||
connClt.Write([]byte(response))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(result.Entries) != 1 {
|
if len(result.Entries) != 1 {
|
||||||
if *debug {
|
if *debug {
|
||||||
logstream.Debug("Got no result, returning 500")
|
logstream.Debug("Got no result, returning 500")
|
||||||
@@ -137,6 +127,16 @@ func handleConnection(connClt net.Conn, conLdap *ldap.Conn) {
|
|||||||
connClt.Write([]byte(response))
|
connClt.Write([]byte(response))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// L'attribut n'existe pas
|
||||||
|
if len(result.Entries[0].Attributes) == 0 {
|
||||||
|
logstream.Err(fmt.Sprintf("Error searching into LDAP: Attribute %s not found for entry %s\n", *ldapAttr, result.Entries[0]))
|
||||||
|
s := strings.Replace(fmt.Sprintf("Attribute not found: %s", *ldapAttr), " ", "%20", -1)
|
||||||
|
response := fmt.Sprintf("500 %s\n", s)
|
||||||
|
connClt.Write([]byte(response))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if *debug {
|
if *debug {
|
||||||
logstream.Debug("Got result, returning " + result.Entries[0].Attributes[0].Values[0])
|
logstream.Debug("Got result, returning " + result.Entries[0].Attributes[0].Values[0])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user