Skip to main content

Hi Team,

I am trying to get details of Project,workbook and Groups having access to workbooks.

but not able to figure out join for the same.

Project and Workbook table have a direct join but in order to jin group table (via Site table) I am getting cartesion product.

7 件の回答
  1. 2022年9月9日 1:48

    @Ayush Kedia​ 

    I have been trying to find a solution, however Max DeRung specifies in his site, there are several points to take into account:

    https://maxderungs.com/tableau-server-permissions/

     

    So, I really give up, on trying to make a query. Instead, I built the following python code, that uses Tableau Server Client, to get a csv of what workbookds a user has view access:

     

    import tableauserverclient as TSC

    import csv

     

    SERVER_NAME = "https://www.yourserver.com"

    SERVER_SITE = ''

    ⌗Credentials needed for Admin, Login with username and password is needed

    ⌗If login with token. TSC PAT auth does not allow impersonation. :(

    SERVER_USERNAME = "yourusername"

    SERVER_PASSWORD = "yourpassword"

     

     

    def main():

    ⌗Sign in with Username and password

    server = TSC.Server(SERVER_NAME, use_server_version=True)

    tableau_auth = TSC.TableauAuth(SERVER_USERNAME, SERVER_PASSWORD, SERVER_SITE)

    ⌗Obtain server sites

    site_auths = []

    with server.auth.sign_in(tableau_auth):

    site_auths.extend(

    site.content_url

    for site in TSC.Pager(server.sites))

    print(site_auths)

    ⌗Create csv file to obtain results

    csvfile = open('permissions.csv', 'w', encoding='utf-8-sig', newline='')

    writer = csv.writer(csvfile, delimiter=";")

    header = ['Site','User', 'Project', 'Workbook']

    writer.writerow(header)

    site_users = []

    for site_auth in site_auths:

    ⌗Get site users

    site_users = []

    with server.auth.sign_in(TSC.TableauAuth(SERVER_USERNAME,SERVER_PASSWORD,site_auth)):

    site_users.extend(

    [user.id, user.name]

    for user in TSC.Pager(server.users))

    server.auth.sign_out()

    for site_user in site_users:

    ⌗Impersonate user

    server, isUserLoggedInToServer = loginToServer(site_auth,site_user[0])

    ⌗Retrieve Workbooks for impersonated user

    if isUserLoggedInToServer == True:

    request_options = setPagination()

    all_workbook_items, pagination_item = server.workbooks.get(request_options)

    for workbook in all_workbook_items:

    if site_auth == "":

    row = ["Default", site_user[1], workbook.project_name ,workbook.name]

    else:

    row = [site_auth, site_user[1], workbook.project_name ,workbook.name]

    writer.writerow(row)

    server.auth.sign_out()

     

    def setPagination ():

    return TSC.RequestOptions(pagesize=1000)

    def loginToServer (*args):

    server = TSC.Server(SERVER_NAME, use_server_version=True)

    print("Login into site:", args[0], " userid:", args[1] )

    if args:

    try :

    tableau_auth = TSC.TableauAuth(SERVER_USERNAME, SERVER_PASSWORD, site_id=args[0], user_id_to_impersonate=args[1])

    server.auth.sign_in(tableau_auth)

    isUserLoggedInToServer = True

    print("Login into server in site ", args[0], " with userid", args[1] ," ", isUserLoggedInToServer)

    except:

    isUserLoggedInToServer = False

    print("Failed Login into server in site ", args[0], " with userid", args[1] ," ", isUserLoggedInToServer)

    else :

    try:

    server.auth.sign_out()

    tableau_auth = TSC.TableauAuth(SERVER_USERNAME, SERVER_PASSWORD, SERVER_SITE)

    server.auth.sign_in(tableau_auth)

    isUserLoggedInToServer = True

    print("Login into server as Administrator in Default Site ", isUserLoggedInToServer)

    except:

    isUserLoggedInToServer = False

    return server, isUserLoggedInToServer

    if __name__ == '__main__':

    main()

    I hope this will work for you. It works for me!!

     

    Take into account that for server admins, that does not appear in the site user list, workbooks won't show. But, I think this code is good enough.

     

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000