@@ -70,12 +70,14 @@ func (h configHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (result
7070 defer span .End ()
7171
7272 start := time .Now ()
73+
7374 defer func () {
7475 h .monitor .SetResponseTimeMetric (
7576 map [string ]string {"operation" : "bind" , "status" : fmt .Sprintf ("%v" , result )},
7677 time .Since (start ).Seconds (),
7778 )
7879 }()
80+
7981 return h .ldohelper .Bind (ctx , h , bindDN , bindSimplePw , conn )
8082}
8183
@@ -85,12 +87,14 @@ func (h configHandler) Search(bindDN string, searchReq ldap.SearchRequest, conn
8587 defer span .End ()
8688
8789 start := time .Now ()
90+
8891 defer func () {
8992 h .monitor .SetResponseTimeMetric (
9093 map [string ]string {"operation" : "search" , "status" : fmt .Sprintf ("%v" , result .ResultCode )},
9194 time .Since (start ).Seconds (),
9295 )
9396 }()
97+
9498 return h .ldohelper .Search (ctx , h , bindDN , searchReq , conn )
9599}
96100
@@ -100,12 +104,14 @@ func (h configHandler) Add(boundDN string, req ldap.AddRequest, conn net.Conn) (
100104 defer span .End ()
101105
102106 start := time .Now ()
107+
103108 defer func () {
104109 h .monitor .SetResponseTimeMetric (
105110 map [string ]string {"operation" : "add" , "status" : fmt .Sprintf ("%v" , result )},
106111 time .Since (start ).Seconds (),
107112 )
108113 }()
114+
109115 return ldap .LDAPResultInsufficientAccessRights , nil
110116}
111117
@@ -115,12 +121,14 @@ func (h configHandler) Modify(boundDN string, req ldap.ModifyRequest, conn net.C
115121 defer span .End ()
116122
117123 start := time .Now ()
124+
118125 defer func () {
119126 h .monitor .SetResponseTimeMetric (
120127 map [string ]string {"operation" : "modify" , "status" : fmt .Sprintf ("%v" , result )},
121128 time .Since (start ).Seconds (),
122129 )
123130 }()
131+
124132 return ldap .LDAPResultInsufficientAccessRights , nil
125133}
126134
@@ -130,31 +138,49 @@ func (h configHandler) Delete(boundDN string, deleteDN string, conn net.Conn) (r
130138 defer span .End ()
131139
132140 start := time .Now ()
141+
133142 defer func () {
134143 h .monitor .SetResponseTimeMetric (
135144 map [string ]string {"operation" : "delete" , "status" : fmt .Sprintf ("%v" , result )},
136145 time .Since (start ).Seconds (),
137146 )
138147 }()
148+
139149 return ldap .LDAPResultInsufficientAccessRights , nil
140150}
141151
142152func (h configHandler ) FindUser (ctx context.Context , userName string , searchByUPN bool ) (f bool , u config.User , err error ) {
143153 _ , span := h .tracer .Start (ctx , "handler.configHandler.FindUser" )
144154 defer span .End ()
155+
156+ h .log .Info ().Int ("users" , len (h .cfg .Users )).Msg ("users in FindUser" )
157+ h .log .Debug ().Str ("userName" , userName ).Bool ("searchByUPN" , searchByUPN ).Msg ("need find in FindUser" )
158+
145159 user := config.User {}
146160 found := false
147161
162+ h .log .Debug ().Int ("users" , len (h .cfg .Users )).Msg ("users in FindUser" )
163+
148164 for _ , u := range h .cfg .Users {
165+ h .log .Debug ().Str ("userName" , userName ).Msg ("found user in FindUser" )
166+
149167 if searchByUPN {
150168 if strings .EqualFold (u .Mail , userName ) {
169+ h .log .Debug ().Str ("userName" , userName ).Msg ("upn match in FindUser" )
170+
151171 found = true
152172 user = u
173+ } else {
174+ h .log .Debug ().Str ("userName" , userName ).Msg ("upn not match in FindUser" )
153175 }
154176 } else {
155177 if strings .EqualFold (u .Name , userName ) {
178+ h .log .Debug ().Str ("userName" , userName ).Msg ("name match in FindUser" )
179+
156180 found = true
157181 user = u
182+ } else {
183+ h .log .Debug ().Str ("userName" , userName ).Msg ("name not match in FindUser" )
158184 }
159185 }
160186 }
0 commit comments