owncloud/core — pull request #12493 by blizzz (2014-11-28 12:53:58+00:00)
Title: LDAP search behaviour modifications

This PR does 2 things:

1. It introduces an occ command that offers to look for LDAP users and groups from command line:

```
ldap:search [--group] [--offset="..."] [--limit="..."] search
```

Specify --group if you want to search for groups instead of users. Offset and Limit default to 0 and 15.

2. a) The creation of search filters has changed. First, the * wildcard is not prepended anymore. It will result in faster search, but you don't find "foobar" when looking for "bar" anymore.

2 b) If the search string contains a whitespace and at least two search attributes are defined, an "advanced" filter is created. It will split the search string into single words and will require that any of them at least appears once in one of the specified search attributes.

Example output for 2):

Before:
```
$ ./occ ldap:search "zombie wood"
```
(empty result set)

```
$ sudo -u www-data ./occ ldap:search "1848"
Allen, Lena (zombie18483)
Crawford, Robyn (zombie18484)
Fisher, Tonya (zombie1848)
Lloyd, Irma (zombie18485)
Moore, Laurie (zombie18487)
O connor, Sheri (zombie18488)
Parker, Penny (zombie18481)
Payne, Patsy (zombie18482)
Sheppard, Melanie (zombie18486)
Stephens, Pearl (zombie18480)
Stewart, Wendy (zombie21848)
Stone, Alison (zombie11848)
West, Pam (zombie18489)
```

Now:
```
$ ./occ ldap:search "zombie wood"
Woods, Iris (zombie766)
Woods, Jenny (zombie659)
Woods, Judy (zombie609)
Woods, Linda (zombie220)
Woods, Nicole (zombie1754)
Woods, Olivia (zombie793)
Woodward, Alice (zombie1682)
Woodward, Arlene (zombie686)
Woodward, Jenny (zombie1375)
```

```
sudo -u www-data ./occ ldap:search "1848"
```
(empty result set)

Note: when trying, playing and testing around, don't forget that LDAP cache is effective. You may reduce the TTL. With APCu, old cache entries are not affected and you might need to wait until they run out, IIRC.

I will do run some queries against AD and collect time for better comparison (yay, benchmarking).

**BUT**: getting rid of prepending * is quite a change, and not everyone may like it. I think we can add an option to enable it in the Advanced settings if someone really wants it back.

(This is against OC 7 on purpose)

cc: @bboule @jnfrmarks @craigpg @MorrisJobke