@@ -56,30 +56,28 @@ func (d *Dell) Authenticate(ctx context.Context, bindDN string, bindPassword []b
56
56
return true
57
57
}
58
58
59
- func (d * Dell ) Authorize (ctx context.Context , req * ldap.SearchRequest ) ([]* ldap.SearchResult , error ) {
60
- searchResults := ldap.SearchResult {}
61
-
59
+ func (d * Dell ) Authorize (ctx context.Context , req * ldap.SearchRequest ) (results []* ldap.SearchResult , err error ) {
62
60
ldapClient , err := providers .ConnectRemoteServer (ctx , d .Config .ClientCaCert , d .Config .RemoteServerName , d .Config .RemoteServerPortTLS )
63
61
defer ldapClient .Close ()
64
62
65
63
if err != nil {
66
64
d .Logger .Warn (err )
67
- return [] * ldap. SearchResult { & searchResults } , err
65
+ return results , err
68
66
}
69
67
70
- d .Logger .Debug ("Filter string is " + req .Filter .String ())
71
-
72
68
// Dell Search request 1: BMC validating the user account is present under the base DN.
73
69
// Pass this request to the backend LDAP server and return the response to the client as is.
74
70
if strings .Contains (req .Filter .String (), "objectClass=posixAccount" ) {
75
71
// req.BaseDN at this point is set to "cn=dell".
76
72
// This needs to be updated to a valid search base (starting point in the tree).
77
73
req .BaseDN = d .Config .BaseDN
78
74
79
- d .Logger .Debug ("Starting Dell Search 1 for " + req .BaseDN )
75
+ d .Logger .Debug ("Starting Dell Search 1 for " + req .BaseDN + ", request filter is " + req . Filter . String () )
80
76
searchResponse , err := ldapClient .Search (req )
81
77
if err != nil {
82
- d .Logger .Warn (fmt .Sprintf ("Remote LDAP search 1 request returned an error: %s" , err ))
78
+ d .Logger .Warn (fmt .Sprintf ("Remote LDAP Search 1 request returned an error: %s" , err ))
79
+ } else {
80
+ d .Logger .Info (fmt .Sprintf ("Remote LDAP Search 1 request succeeded, response: %+v" , searchResponse ))
83
81
}
84
82
return searchResponse , nil
85
83
}
@@ -89,7 +87,7 @@ func (d *Dell) Authorize(ctx context.Context, req *ldap.SearchRequest) ([]*ldap.
89
87
if strings .Contains (req .Filter .String (), "memberUid=" ) {
90
88
// req.BaseDN at this point would contain "cn=dell", to identify this BMC as Dell.
91
89
// (e.g. "cn=dell,cn=fooUsers,ou=Group,dc=example,dc=com")
92
- d .Logger .Debug ("Starting Dell Search 2 for " + req .BaseDN )
90
+ d .Logger .Debug ("Starting Dell Search 2 for " + req .BaseDN + ", request filter is " + req . Filter . String () )
93
91
94
92
// Strip out "cn=dell," from the request Base DN.
95
93
mainDN := strings .Replace (req .BaseDN , "cn=dell," , "" , 1 )
@@ -98,7 +96,7 @@ func (d *Dell) Authorize(ctx context.Context, req *ldap.SearchRequest) ([]*ldap.
98
96
req .BaseDN = strings .Replace (mainDN , "cn=" , "cn=" + prefix , - 1 )
99
97
100
98
// Indicate that we have changed something...
101
- msg := "Performing actual search for " + req .BaseDN
99
+ msg := "Performing actual search for " + req .BaseDN + ", request filter is " + req . Filter . String ()
102
100
if prefix != "" {
103
101
msg += " after adding " + prefix
104
102
}
@@ -107,7 +105,7 @@ func (d *Dell) Authorize(ctx context.Context, req *ldap.SearchRequest) ([]*ldap.
107
105
// The actual search.
108
106
searchResponse , err := ldapClient .Search (req )
109
107
if err != nil {
110
- d .Logger .Warn (fmt .Sprintf ("Remote LDAP search 2 request returned an error: %s" , err ))
108
+ d .Logger .Warn (fmt .Sprintf ("Remote LDAP Search 2 request returned an error: %s" , err ))
111
109
}
112
110
113
111
if len (searchResponse ) > 0 {
@@ -117,5 +115,7 @@ func (d *Dell) Authorize(ctx context.Context, req *ldap.SearchRequest) ([]*ldap.
117
115
}
118
116
}
119
117
120
- return []* ldap.SearchResult {& searchResults }, nil
118
+ d .Logger .Info (fmt .Sprintf ("Filter %s not found in group %s" , req .Filter .String (), req .BaseDN ))
119
+
120
+ return results , nil
121
121
}
0 commit comments