I’ve got some LDAP data I’m trying to pipe into a ruby script.
Here is an example of the data there are multiple groups (dn) in the
real data set. Sometimes the groups (dn) don’t have a “seeAlso” or
“owner” associated with it:
dn: cn=test_group,ou=groups,dc=example,dc=com
owner: uid=jsmith,ou=people,dc=example,dc=com
seeAlso: uid=bwilliams,ou=people,dc=example,dc=com
Here is my script:
#!/usr/bin/ruby
unless STDIN.tty?
while((line = STDIN.gets))
print $1 if /dn: cn=(.),ou=groups,dc=example,dc=com/
print $1+’@example.com’ if /owner:
uid=(.),ou=people,dc=example,dc=com/
print $1+’@example.com’ if /seeAlso:
uid=(.*),ou=people,dc=example,dc=com/
print “\n”
end
else
end
The output of my script:
test_group
[email protected]
[email protected]
What I want the output to look like:
test_group [email protected], [email protected]
Any help would be appreciated.
Thanks,
Kent