Splunk Search

Can you help me build a Splunk query to get all associated members (Username and UserId) of the LDAP group?

bhaskarasplunk
Explorer

I tried this query to get all the members of a particular LDAP group:


| rest /servicesNS/nobody/system/admin/LDAP-groups|search title="SPLUNK-group-name"
|dedup title|fields users| rex field=users "CN=(?[^,]+)"|table user
| mvexpand user
|join realname[|rest /services/authentication/users splunk_server=local|search realname=*|table title]

Result:

user title


john abcd

sam abcd

nike abcd

rams abcd

My desired result should look like this: I should get unique ID associated with each member.

user title


john abcd

sam efgh

nike ijkl

rams mnop

I tried to replace the * with 'user' in the above query:

 join realname[|rest /services/authentication/users splunk_server=local|search realname=user|table title]

but I'm not able to get any results — showing as no results. Can anyone please help with this?

Thanks,
Bhaskara.

Tags (3)
0 Karma

woodcock
Esteemed Legend

DO NOT USE JOIN. Try this:

| rest /servicesNS/nobody/system/admin/LDAP-groups 
| search title="WHATEVER" 
| dedup title 
| fields users| rex field=users "CN=(?<user>[^,]+)" 
| table user 
| mvexpand user 
| appendpipe
[| rest /services/authentication/users splunk_server=local 
 | search realname=* 
 | rename title as user
 | table user realname]
| stats values(*) AS * BY user
0 Karma

chrisyounger
SplunkTrust
SplunkTrust

Does this work for you:

| rest /servicesNS/nobody/system/admin/LDAP-groups 
| search title="WHATEVER" 
| dedup title 
| fields users| rex field=users "CN=(?<user>[^,]+)" 
| table user 
| mvexpand user 
| join user type=outer 
    [| rest /services/authentication/users splunk_server=local 
    | search realname=* 
    | rename title as user
    | table user realname]

All the best

0 Karma
Get Updates on the Splunk Community!

Best Strategies to Optimize Observability Costs

 Join us on Tuesday, May 6, 2025, at 11 AM PDT / 2 PM EDT for an insightful session on optimizing ...

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...