Hi I can't figure out how to verify if a user belong to one o more group under Linux os using java 7 nio library.
Can anyone help me about this issue?
Hi I can't figure out how to verify if a user belong to one o more group under Linux os using java 7 nio library.
Can anyone help me about this issue?
You can try to read the file
/etc/group
.I have developed a class to easily query this file:
This code maps the
/etc/group
file and keep a map of groups-their users set. I have developed just one query method (belongs2group
) but it is fairly easy to add methods to list all groups and/or all users.This code is written using the old-fashioned-mainstream java io-api but I think it can be easily adapted to nio. Let me know if you need me to complete that step.