0

I'm using MacFUSE to create a cool filesystem. I'd like to set the NSFileOwnerAccountID and NSFileGroupOwnerAccountID attributes for the files on it, but the underlying framework I use only gives me user names.

How can I get an account ID from an account name under Mac OS X using Cocoa or other built-in frameworks?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
zneak
  • 134,922
  • 42
  • 253
  • 328

2 Answers2

0

What you could do is get a list of all the CSIdentity objects and build a "username to identity" map. Once you have the identity object, you can get a bunch of other information from it.

More info:

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
  • The Collaboration framework (linked from the Identity Services Programming Guide) will probably be easier to use. – zneak Nov 16 '10 at 21:14
0

These are just UID and GID numbers. Try the getpwnam (for user) and getgrnam (for group) functions; each returns a structure that contains the ID number, among other things.

Alternatively, just use NSFileOwnerAccountName and NSFileGroupOwnerAccountName instead of the …AccountID versions.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370