I have the parameters (especially the userid and the groupid) of a file read with the stat
command and I work in a network where the users and groups are specified on an ldap server.
I've got the username out of the result of the command getent passwd userid
.
Now my idea was to get the groupname with getent group groupid
, but this doesn't work.
Can anyone tell me where I have my mistake or how I get the groupname?
Thanks!
You probably have a configuration issue where either you've not got a line like:
in your
/etc/nsswitch.conf
.or your group information on the ldap server is in a form that doesn't have group id numbers e.g. of type
groupOfNames
,groupOfUniqueNames
instead of being of typeposixGroup
.Only posixGroup has the appropriate attributes that permit it's use as a valid group in linux/unix (i.e. the group id number which is needed to match). In that situation the ldap server doesn't return valid groups.
You can have a perfectly functioning ldap configuration without any or all the remote groups being present in the output from
getent group
.Leaving aside the possibility that you're supplying a wrong group ID, this might be a bug in LDAP setup, which manifests in reverse group resolution not working. This is reinforced by the fact that this works on a plain "files" setup.
The getent(1) states:
This could mean that getgrgid(3) fails on your setup.
To test this compile this program (getgrgid_test.c) with "make getgrgid_test":
Then run it with your gid like this:
If it doesn't produce a group name report to your system administrators.
Otherwise, if it does work, but "getent group GID" doesn't, it's a bug in "getent".