Find the name of Directory Service User via Login Script in Perl
I made a login script in Perl which has to run on Mac OS X clients and record the Logged in Directory Service user name.
I tried using getlogin()
, getpwuid($<)
respectively.
Now the problem is that since the login script runs as root on the system when the client logs in, getpwuid($<)
always gives me the username as root. When using the getlog开发者_如何学Goin()
function, i do get the user name but for the user who logged in previously on the system.
I am using an open directory environment consisting of a Mac OS server.
Any ideas on how to solve this issue?
Are you talking about a loginhook script? If so, it'll get passed the username as an argument, so $ARGV[0]
should be what you need.
Can you just use last
? (man page) The log-in names and the duration are already in the wtmp
file. I don't think you need to log them yourself.
精彩评论