Importing a User List?

How can I import a list of Active Directory users into the Deadline Database? I’m not a capable scripter and know nothing about directly administering a database file, so I’ll need some extra help on this one.

I can get a CSV out of Active Directory but don’t know where to go from there.

IN case you’re wondering why I’m asking this:

I need to explicitly deny a generic user login called “student” from accessing Deadline, yet I need any new user that logs in to be able to use Deadline. Because “student” is part of the “everyone” group I can’t deny it access without disabling “everyone”. Disabling “everyone” makes it so the new user has to get an admin to move them into the “allowed” group.

I can get it to work by typing in the names beforehand and adding them to the allowed list. I have 400 users, though, and I’d rather import a list to the database if that’s what needs to be done.

Well, interacting directly with the database is pretty frowned upon in these parts (“unsupported”), but I did write an AD import script I’ve been meaning to throw up on the Github project.

Here’s the Deadline side of that script for all to enjoy:

'''
    Pull data dumped by 
'''
import csv
import os

from Deadline.Scripting import RepositoryUtils
from Deadline.Users import UserInfo

FILENAME = 'C:\ActiveDirectorySync\output.csv' # This is where input file lives
DEADLINE_GROUP_NAME = 'SomeGroupName' # This is the Deadline group

def __main__():
    '''Given a list of usernames, email addresses, and groups make a bunch of users with
    the Deadline API '''

    file = open(FILENAME)
    user_data = csv.DictReader(file)

    print("Saving users to Deadline")

    group = []
    for user in user_data:
        #Create Deadline user
        user_info = UserInfo(user['samAccountName'])

        #Set user name and email
        user_info.UserName = user['samAccountName']
        user_info.UserEmailAddress = user['mail']

        #Save the user
        print '.',
        RepositoryUtils.SaveUserInfo(user_info)

        #Add user to group list
        group.append(user['samAccountName'])

    RepositoryUtils.SetUsersForUserGroups(group, [DEADLINE_GROUP_NAME])


if __name__ == '__main__':
    __main__()

And here’s the AD powershell script:

$searchRoot = "OU=WHERE_IN_AD_THE_STUDENTS_LIVE,DC=EXAMPLE,DC=COM"

Get-ADGroupMember "THE_NAME_OF_THE_AD_GROUP" | Sort -Property Name | Select Name, samAccountName, mail  | Export-Csv -Path:'C:\ActiveDirectorySync\output.csv' -NoTypeInformation

You’d run both this way:

powershell.exe -ExecutionPolicy Bypass -Command "& {& '.\GrabUsers.ps1' }"
"%DEADLINE_PATH%\deadlinecommand" executescript deadlinesync.py

I can help you tweak as needed. The idea is that AD becomes the one true source of knowledge and just blasts away everything else. Downside, this does not cull the user list so it’ll keep growing.

Wow, this is amazing! I’ll give it a shot - thanks so much!

Welcome! Feel free to post any tweaks over here. There are a few more properties you can set if you care to do so:
docs.thinkboxsoftware.com/produ … _info.html

@ruthless here’s that script I mentioned in your support ticket! I forgot about this guy.

Privacy | Site terms | Cookie preferences