getpwnam fails for user created with dscl

I have created a user with dscl create command. However when I use getpwnam to fetch the created user, it fails.

However it works fine with groups.

How do I retrieve the user details using an api?

If getpwnam isn’t finding the user then, almost by definition, the user record wasn’t created properly. My advice is that you create users with sysadminctl rather than the much more low level dscl.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

getpwnam fails for user created with dscl
 
 
Q