Skip to content

C# library to replicate Active Directory objects in Qlik NPrinting

License

Notifications You must be signed in to change notification settings

workcontrolgit/nprinting-adsync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdSyncToNprinting - Active Directory Synchronization to Qlik NPrinting

AdSyncToNprinting is a simple C# demo app that allow to create and maintain a replica of objects living in Active Directory in NPrinting. It is composed by the following libraries:

  • ADSyncCSharp: C# Active Directory Synchronization library
  • NPrintingRestClient: C# Rest client for NPrinting API

What is ADSyncCSharp?

ADSyncCSharp is a C# library that allows to fetch Groups and related Users from an Active Directory Controller and import them into NPrinting via REST API. It supports Full and Incremental sync.

Getting started

Edit adsyncnprinting.config file located in ADSyncDemoApp to define the necessary details on how to connect to Active Directory, NPrinting and what exactly you want to replicate.

Run the initial full synchronization

Run the build.bat to build the project. The build process create an executable file that you can use to start the application:

ADSyncDemoApp.exe -u domain\username -p password

with the following parametes for the Active Directory User account: -u domain\username -p password

An instance of NPrinting Server needs to be up and running to persist the replicated data.

ADSync tool considerations:

  • Support for Full or Incremental sync
  • Extension Point for different merge policies for New/Updated or Deleted objects
  • Configurable through config file.
  • Support for adding/customizing Active Directory queries
  • No recovery mechanism in case of failure during the import process in NPrinting. A failure or partially completed import would required a new sync.
  • Extension Point to store and handle last sync details (for incremental sync).
  • Support for NPrinting NTLM API client to use during the sync process.
  • One way sync from Active Directory to NPrinting. Additional modification made in NPrinting to users or groups imported from Active Directory may cause out of sync.

Assumptions and constraints regarding the AD directory structure and NPrinting.

The basic idea is to export all the users defined in Active Directory Groups where the Group's Name is defined by the following pattern::

  • Group's name must ends with "_roleName" where "roleName" has to match an existing Role in NPrinting. An example of Group's name could be "NPrinting_Developer" or "NewGroup_Administrator". All the users who belong to the Group will get the Role defined by the Group's name suffix.
  • Renaming existing Groups (previously imported in NPrinting) are managed as new Groups.
  • A change to the email address of a previously imported User will be treated as a new User in NPrinting.

Active Directory constraints:

  • "Flat" structure for Groups and Users, No support for nested groups.
  • An "OU" or in general a root folder must be define in AD in order to kickoff the import process from a defined entry point.
  • No restriction on the User name.
  • Users must have the email address added in AD and should not be changed.
  • User must have a Domain Account in order to be able to login in NPrinting after the import through NTLM.
  • An Active Directory restore would required a new Full sync to NPrinting.
  • "Deleted Objects Container" must be enable in order to reflect the deleted objects in NPrinting.

API/NPrinting constraints:

  • Imported users in NPrinting will have to login using NTLM. To login through Username/Password, he/she would have to reset the password first.
  • NPrinting roles need to be added before running the sync.
  • Groups with the same name are consider already imported as well as Users with same email address. In this case only updates will be performed.
  • NPrinting REST API client needs Admin privileges in order to being able to create/update/remove Groups/Users. (NPrinting Client use NTLM authentication).

Qlik.NPrinting.Rest.Client - C# library for Qlik NPrinting API

You can extend your reporting system by using the Qlik NPrinting API. This API provides endpoints to perform operations on apps, users, groups, reports, filters, and so on. For all requests, the data returned is filtered based on user permissions. That is, if a user is not authorized to access a certain object, that object is not returned in the reponse. API Stability: Experimental. Deprecation period: None. Can change at any point and should be used only to evaluate upcoming functionality.

This C# SDK is automatically generated by the Swagger Codegen project:

  • API version: 0.2.0
  • SDK version: 1.0.0

Frameworks supported

  • .NET 4.6 or later

Dependencies

The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json

Installation

Run the following command to generate the DLL`

  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using Qlik.NPrinting.Rest.Client.Api;
using Qlik.NPrinting.Rest.Client.Client;
using Qlik.NPrinting.Rest.Client.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out Qlik.NPrinting.Rest.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Getting Started

using System;
using System.Diagnostics;
using Qlik.NPrinting.Rest.Client.Api;
using Qlik.NPrinting.Rest.Client.Client;
using Qlik.NPrinting.Rest.Client.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {
            
            ApiClient apiClient = NPrintingApiFactory.GetNPrintingApiClient("https://localhost:4993");

            var apiInstance = new AppsApi(apiClient);
            var sort = sort_example;  // string | A comma separated list of fields to use for sorting the apps. Allowed field values are \"name\" and \"created\". Fields can be prefixed by \"+\" and \"-\" to indicate, respectively, ascending and descending order.  Usage example: /apps?sort=+name,-created  (optional) 
            var offset = 56;  // int? | The number of entries to skip. Default is 0. (optional)  (default to 0)
            var limit = 56;  // int? | The maximum number of entries to return. Default is 50. (optional)  (default to 50)

            try
            {
                // Generates the list of Qlik NPrinting Apps.
                AppListResponse result = apiInstance.AppsGet(sort, offset, limit);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling AppsApi.AppsGet: " + e.Message );
            }
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://localhost:4993/api/v1

Class Method HTTP request Description
AppsApi AppsGet GET /apps Generates the list of Qlik NPrinting Apps.
AppsApi AppsIdGet GET /apps/{id} Returns details about a specific app.
AuthenticationApi LoginNtlmGet GET /login/ntlm Authenticates the caller using NTLM authentication.
FiltersApi FiltersGet GET /filters Gets the list of filters.
FiltersApi FiltersIdDelete DELETE /filters/{id} Deletes a filter.
FiltersApi FiltersIdGet GET /filters/{id} Gets details of the specified filter.
FiltersApi FiltersIdPut PUT /filters/{id} Updates an existing filter.
FiltersApi FiltersPost POST /filters Creates a new filter.
GroupsApi GroupsGet GET /groups Gets the groups.
GroupsApi GroupsIdDelete DELETE /groups/{id} Deletes a group.
GroupsApi GroupsIdGet GET /groups/{id} Get a specific group.
GroupsApi GroupsIdPut PUT /groups/{id} Updates a group.
GroupsApi GroupsIdUsersGet GET /groups/{id}/users Gets the users in a group.
GroupsApi GroupsPost POST /groups Adds a new group.
ReportsApi ReportsGet GET /reports Gets the list of reports.
ReportsApi ReportsReportIdGet GET /reports/{reportId} Gets details about a specific report.
RolesApi RolesGet GET /roles Get the roles.
RolesApi RolesIdGet GET /roles/{id} Get a specific role.
RolesApi UsersIdRolesGet GET /users/{id}/roles Gets the roles for a user.
RolesApi UsersIdRolesPut PUT /users/{id}/roles Updates the roles for a user.
UsersApi UsersGet GET /users Gets the user list.
UsersApi UsersIdDelete DELETE /users/{id} Delete a user.
UsersApi UsersIdFiltersGet GET /users/{id}/filters Gets the filters for a user.
UsersApi UsersIdFiltersPut PUT /users/{id}/filters Update the filters for a user.
UsersApi UsersIdGet GET /users/{id} Gets a specified user.
UsersApi UsersIdGroupsGet GET /users/{id}/groups Gets a list of groups.
UsersApi UsersIdGroupsPut PUT /users/{id}/groups Updates a user's list of groups.
UsersApi UsersIdPut PUT /users/{id} Update an existing user.
UsersApi UsersIdRolesGet GET /users/{id}/roles Gets the roles for a user.
UsersApi UsersIdRolesPut PUT /users/{id}/roles Updates the roles for a user.
UsersApi UsersPost POST /users Adds a user.

Documentation for Models

Documentation for Authorization

All endpoints do require authorization.

License

See LICENSE.txt.

Contributing

Please follow the instructions in CONTRIBUTING.md.

About

C# library to replicate Active Directory objects in Qlik NPrinting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.8%
  • Batchfile 0.2%