Skip to main content

Hi guys



im trying to get my AD deparment.



So when i do



dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton



i want to be able to get my department



dsAttrTypeNative:department:
Information Systems



Problem is im having problem outputting just Information Systems.



Can anyone help me?



Thanks

Hey fella,



Is that on 2 lines?



Have a look @ head & tail.



Something like that. Is this fot populating AD info innthe Jss?


had a bit of a blank lol



this worked



dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton department | tr -d '
' | awk '{$1 =""; print }' | sed '1s/^.//'

Not the prettiest way to do it, but grep might work as well. A quick test of this worked for me:



dscl /Active Directory/INTEGERDALLAS/All Domains/ -read /Users/swood dsAttrTypeNative:department | grep -oi "information systems"


That returned "Information Systems" for my user, and when I tried a user that had a different department, it returned blank. For users that had no department it returned "No such key: dsAttrTypeNative:department".


Hi Ben



yeah its on the second line. I know theres lots of ways of doing things and eventually thought of it.



Its there an easier way with head and tail?



would be easier to remember lol


bit of a problem trying to get my original command in an Applescript :(



Anyone know how i can do this?


Brilliant Steve. Im trying to get this in an applescript and having problems with it though. I have tried



set Department to do shell script "dscl /Active Directory/RUFUS_DOMAIN/All Domains/ -read /Users/tkimpton dsAttrTypeNative:department | grep -oi "Information Systems"

I just tried this and received the proper info back:



tell application "Finder"

set Department to do shell script "dscl /Active\\ Directory/INTEGERDALLAS/All\\ Domains/ -read /Users/swood dsAttrTypeNative:department | grep -oi 'information systems'"

display dialog Department

end tell


The trick for me were the double back slashes and then the single quote in the grep statement.


Thanks Steve much appreciated, you brought me back from the brinks of madness



This is what is used for the applescript in the end



set loggedInUser to do shell script "whoami"

set ISDepartment to do shell script "dscl /Active\\ Directory/RUFUS_DOMAIN/All\\ Domains/ -read /Users/" & loggedInUser & " dsAttrTypeNative:department | grep -oi 'Information Systems'"

hi do we have any updated script to update AD user full name department email id and more to update to inventory via extension attribute or policy can help