Apple Script to mount drives based on users AD group membership

Posted on 2011-10-21
Last Modified: 2012-05-12
I have created an script that mounts drives users need but I have have to add each share in the script. I am looking for a script that looks at the users group membership and then mounts the share if they are a member of that group/share.

Question by:keevern
    LVL 39

    Expert Comment

    See this posting ... on EE

    The command "whoami" gives your current username
    The command "groups" will give you a list of groups you are a member of
    You could SCAN the list of groups .. if it finds a match you can execute a SMB mount command.
    LVL 10

    Expert Comment

    Login scripts execute as the root user and therefore "whoami" and "groups" return  information for root. To get the actual user logging in you need to execute the following in your script:
    username=`eval echo $1`.
    Unfortunately, I am not sure what you could do for the group info.
    LVL 1

    Accepted Solution

    --do shell script "id"
    set thescript to "id"
    set userinfo to do shell script thescript

    if (userinfo contains "AD group name") then
          mount volume "smb://server/share"
    end if
    LVL 1

    Author Closing Comment

    Figured this out. You can also use.
    set user_name to (short user name of (system info)) to get the local logged in user.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Yesterday Apple introduced their revolutionary new iOS 5 operating system that claims to be the ultimate mobile technology interface. One of the biggest innovations of the new operating system is the introduction of the iCloud computing network. Thi…
    There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
    Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
    Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now