You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`:uid` or `:filter` - Either `:uid` (the LDAP attribute for username, default: "sAMAccountName") or `:filter` (LDAP filter for searching user entries). If `:filter` is provided, `:uid` is not required.
182
+
-`:uid` or `:filter` - Either `:uid` (the LDAP attribute for username, default: "sAMAccountName") or `:filter` (LDAP filter for searching user entries). If `:filter` is provided, `:uid` is not required. Note: This `:uid` option is the search attribute, not the top-level `auth.uid` in the OmniAuth result.
183
183
184
184
### Optional Options
185
185
@@ -192,6 +192,36 @@ The following options are available for configuring the OmniAuth LDAP strategy:
192
192
-`:allow_anonymous` - Whether to allow anonymous binding (default: false).
193
193
-`:logger` - A logger instance for debugging (optional, for internal use).
194
194
195
+
### Auth Hash UID vs LDAP :uid (search attribute)
196
+
197
+
- By design, the top-level `auth.uid` returned by this strategy is the entry's Distinguished Name (DN).
198
+
- The configuration option `:uid` controls which LDAP attribute is used to locate the entry (or to build the filter), not the value exposed as `auth.uid`.
199
+
- Your LDAP "account name" (for example, `sAMAccountName` on Active Directory or `uid` on many schemas) is exposed via `auth.info.nickname` and is also available in `auth.extra.raw_info`.
200
+
201
+
Why DN for `auth.uid`?
202
+
203
+
- DN is the canonical, globally unique identifier for an LDAP entry and is always present in search results. See LDAPv3 and DN syntax: RFC 4511 (LDAP protocol) and RFC 4514 (String Representation of Distinguished Names).
204
+
- Attributes like `uid` (defined in RFC 4519) or `sAMAccountName` (Active Directory–specific) may be absent, duplicated across parts of the DIT, or vary between directories. Using DN ensures consistent behavior across AD, OpenLDAP, and other servers.
205
+
- This trade-off favors cross-directory interoperability and stability for apps that need a unique identifier.
206
+
207
+
Where to find the "username"-style value
208
+
209
+
-`auth.info.nickname` maps from the first present of: `uid`, `userid`, or `sAMAccountName`.
210
+
- You can also read the raw attribute from `auth.extra.raw_info` (a `Net::LDAP::Entry`):
# Or, directly from raw_info (case-insensitive keys):
218
+
sam = auth.extra.raw_info[:samaccountname]&.first
219
+
# ...
220
+
end
221
+
```
222
+
223
+
If you need top-level `auth.uid` to be something other than the DN (for example, `sAMAccountName`), you'll currently need to read it from `auth.info.nickname` (or `raw_info`) in your app. Changing the top-level `uid` mapping would be a breaking behavior change for existing users; if you have a use-case, please open an issue to discuss a configurable mapping.
224
+
195
225
## 🔧 Basic Usage
196
226
197
227
The strategy exposes a simple Rack middleware and can be used in plain Rack apps, Sinatra, or Rails.
0 commit comments