How to get the macOS user login Password requirements in Swift

Hi Team, How can we fetch the macOS password requirement(for setting a new password) that are inforce during login for users? Is there a way to get this info in swift programming?

Answered by DTS Engineer in 850073022

Are you referring to the password policy that might be applied in a managed environment? If so, those come from the user’s directory record, and thus you can fetch them using the Open Directory framework. Historically I’d use -passwordPolicyAndReturnError: but that’s been deprecated. The deprecation chain is hard to follow but I think that it ultimately ends in the accountPolicies() method.

Note The docs for that routine are just a stub. For more hints, check out the doc comment for -setAccountPolicies:error: in <OpenDirectory/ODRecord.h>.

Share and Enjoy

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

Are you referring to the password policy that might be applied in a managed environment? If so, those come from the user’s directory record, and thus you can fetch them using the Open Directory framework. Historically I’d use -passwordPolicyAndReturnError: but that’s been deprecated. The deprecation chain is hard to follow but I think that it ultimately ends in the accountPolicies() method.

Note The docs for that routine are just a stub. For more hints, check out the doc comment for -setAccountPolicies:error: in <OpenDirectory/ODRecord.h>.

Share and Enjoy

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

How to get the macOS user login Password requirements in Swift
 
 
Q