Oooh! CSIdentityQueryCreateForCurrentUser
looks like it, maybe? I will experiment! Thank you! 😄
Edited to Add
Yes, that worked! My code here is really ugly, but it does seem to work. So thank you very much!
{
CSIdentityQueryRef query;
CFErrorRef error;
CFArrayRef identityArray;
// create the identity query based on name
query = CSIdentityQueryCreateForCurrentUser(kCFAllocatorDefault);
// execute the query
if (CSIdentityQueryExecute(query, kCSIdentityQueryGenerateUpdateEvents, &error))
{
printf("Success!\n");
// retrieve the results of the identity query
identityArray = CSIdentityQueryCopyResults(query);
printf("Got %lu entries in the array\n", CFArrayGetCount(identityArray));
for (size_t indx = 0; indx < CFArrayGetCount(identityArray); indx++) {
CSIdentityRef identity = (CSIdentityRef)CFArrayGetValueAtIndex(identityArray, indx);
CFStringRef name = CSIdentityGetPosixName(identity);
const size_t maxSize = 1024;
char *buffer = (char *)malloc(maxSize);
if (CFStringGetCString(name, buffer, maxSize,
kCFStringEncodingUTF8)) {
printf("Current user = %s\n", buffer);
} else {
printf("Could not get user string?\n");
}
}
// do something with identityArray
// return (CSIdentityRef)CFArrayGetValueAtIndex(users, 0);
}
CFRelease(query);
}