In my Cocoa app how can I get the current user's domain when they're logged in via Active Directory?
I need to determine two things:
I've found references to Directory Services and the Open Directory Programming Guide but the latter is 10.6 only (I must support 10.5+) and I could not find any examples for the former that gave me an idea of what I needed to do.
You can use the dsconfigad command to bind a Mac to Active Directory via the terminal app. All you need to do is run the following command. Note that you need to replace the domain name, computer name, password, etc. with your specific information.
As a result, your users can leverage their Azure AD user names (User Principal Name) and passwords as Managed Apple IDs. They can then use their Azure AD credentials to sign in to iCloud on their assigned iPad or Mac and even to iCloud on the web. Students and employees can also use it to sign in on Shared iPad.
dsconfigad -show
It will tell whether you are bound to a directory and details about that directory if bound. Then you will know how to script dscl.
I think you can use same idea as here:
Mac OSX: Determing whether user account is an Active Directory user vs. local user using objective-c
you just need to look for Network or Authentication node (it's kODNodeTypeAuthentication type) and query it for kODAttributeTypeRecordName with query value set to current user name. Then look at search result, you'll find many interesting things there :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With