S
Sean Hussey
Hi everyone,
I'm trying to output a YAML file that will list users and some of
their LDAP attributes. For instance (non-YAML):
uid: seanhussey
dn: uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
anotherattr: 39392:12341
The last attr is formatted like that, with the colon, in case that's import=
ant.
What I'd like to do is write this out to a file and then be able to
read it back in such that I can iterate over every user and work on
the data. My first pass at this gave me this format:
seanhussey:
dn: uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
anotherattr: 39392:12341
Etc, for every user. Although I write a hash to the file, when it all
comes out, it's a bunch of arrays. Trying to access pieces of data by
their name doesn't work.
users =3D YAML.load_file("users.yaml")
users.each { |user|
puts user[0]
user[1].each { |a|
puts a[0]
puts a[1]
}
}
This gets me:
seanhussey
anotherattr
39392:12341
dn
uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
How do I get to user[:uid], user[:anotherattr] and user[:dn] ?
Thank you!
Sean
I'm trying to output a YAML file that will list users and some of
their LDAP attributes. For instance (non-YAML):
uid: seanhussey
dn: uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
anotherattr: 39392:12341
The last attr is formatted like that, with the colon, in case that's import=
ant.
What I'd like to do is write this out to a file and then be able to
read it back in such that I can iterate over every user and work on
the data. My first pass at this gave me this format:
seanhussey:
dn: uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
anotherattr: 39392:12341
Etc, for every user. Although I write a hash to the file, when it all
comes out, it's a bunch of arrays. Trying to access pieces of data by
their name doesn't work.
users =3D YAML.load_file("users.yaml")
users.each { |user|
puts user[0]
user[1].each { |a|
puts a[0]
puts a[1]
}
}
This gets me:
seanhussey
anotherattr
39392:12341
dn
uid=3Dseanhussey,dc=3Dcompany,dc=3Dcom
How do I get to user[:uid], user[:anotherattr] and user[:dn] ?
Thank you!
Sean