Skip to content

Commit a165064

Browse files
committed
fix build error
add test
1 parent 498933b commit a165064

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

providers/directory/search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"encoding/base64"
7+
"encoding/binary"
78
"fmt"
89
"github.com/brianvoe/gofakeit/v6"
910
log "github.com/sirupsen/logrus"

providers/directory/search_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,41 @@ func TestSearch_Schema(t *testing.T) {
243243
require.Len(t, res.Results, 1)
244244
},
245245
},
246+
{
247+
name: "ldap filter objectSid using AD style",
248+
input: `{ "files": [ "./users.ldif" ] }`,
249+
reader: &dynamictest.Reader{Data: map[string]*dynamic.Config{
250+
"file:/users.ldif": {Raw: []byte(`
251+
dn:
252+
namingContexts: dc=example_domain_name
253+
subschemaSubentry: cn=schema
254+
255+
dn: cn=schema
256+
objectClass: top
257+
objectClass: subschema
258+
attributeTypes: ( 1.2.3.4.5.6.7.8 NAME 'objectSid' DESC 'objectSid' EQUALITY activeDirectoryObjectSidMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
259+
260+
dn: cn=user1
261+
objectSid:: AQUAAAAAAAUVAAAA0gKWSdIClknSApZJ6QMAAA==
262+
263+
dn: cn=user2
264+
objectSid:: AQUAAAAAAAUVAAAAF8sUcR3r8QcekDXQw9wAAA==
265+
`)},
266+
}},
267+
test: func(t *testing.T, h ldap.Handler, err error) {
268+
require.NoError(t, err)
269+
270+
rr := ldaptest.NewRecorder()
271+
h.ServeLDAP(rr, ldaptest.NewRequest(0, &ldap.SearchRequest{
272+
Scope: ldap.ScopeWholeSubtree,
273+
Filter: fmt.Sprintf("(objectSid=S-1-5-21-1234567890-1234567890-1234567890-1001)"),
274+
}))
275+
res := rr.Message.(*ldap.SearchResponse)
276+
277+
require.Len(t, res.Results, 1)
278+
require.Equal(t, "cn=user1", res.Results[0].Dn)
279+
},
280+
},
246281
}
247282

248283
t.Parallel()

0 commit comments

Comments
 (0)