I need help in getting the current logged in user in Mac OSX using object-c from accessed via java's Rococoa

300 Views Asked by At

I am new in Mac OSX and I wanted to get the logged in user for an intranet authentication app I am working on at work. I have read about Rococoa and how it can be used to access native object-c methods and properties. Is there a beginner tutorial or user guide to this? Please help.

2

There are 2 best solutions below

0
Angel O'Sphere On BEST ANSWER

You only need to get the environment varriable "USER" with the standard C call getEnv(). (Like on any other OS ;D)

0
Dennis Mungai On

Narshion.

You can adapt this C example and call it up from within the Rococoa environment:

#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("test\n");
const char* s = getenv("USER");
printf("USER :%s\n",(s!=NULL)? s : "getenv returned NULL");
printf("end test\n");
}

Regards,

Brainiarc7