Git Product home page Git Product logo

nprinting-adsync's Introduction

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.

nprinting-adsync's People

Contributors

peol avatar renovate-bot avatar vus-qlik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nprinting-adsync's Issues

error nprinting-adsync

I have this error when i run the script

ADSyncDemoApp.exe -u ....... -p ....
Performing a full sync.
System.DirectoryServices.DirectoryServicesCOMException (0x80072030): There is no
such object on the server.

at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne
)
at System.DirectoryServices.DirectorySearcher.FindAll()
at ADSyncCSharp.Service.FullSyncOperation.execute(String querySearchFilter, I
EntryProcessor`1 entryProcessor)
at ADSyncCSharp.Service.ActiveDirectorySyncService.FullSync()
at ADSyncDemoApp.Component.AdSync.Sync()
at ADSyncDemoApp.Program.Main(String[] args)


I check my Active Directory and Nprinting configuration in adsyncnprinting.config file , the syntax and the configuration is correct

Thank you for your help

Malformed request when Domainaccount isn't empty

Description

I'm trying to to use the C# library for creating users in NPrinting. I can create users (UsersPost) from code as along as I don't set the Domainaccount field to something else than "". The same problem exists when I try to modify a user with UsersIdPut.

Steps to Reproduce

The following code example crashes

      ApiClient apiClient = NPrintingApiFactory.GetNPrintingApiClient("https://hostname:4993/");
      var userApi = new UsersApi(apiClient);

       UserRequest user = new UserRequest(Email: "[email protected]", 
            Domainaccount: "example",
            Username: "example",
            Enabled: true, 
            Password: "garbage", 
            Timezone: "CET",
            Locale: UserLocale.En);
        
        userApi.UsersPost(user);
Expected behavior

A user is created with the domainaccount field set

Actual behavior

An exception is thrown

Qlik.NPrinting.Rest.Client.Client.ApiException
HResult=0x80131500
Message=Error calling UsersPost: {"error":{"code":400,"message":"Malformed parameters"}}
Source=Qlik.NPrinting.Rest.Client
StackTrace:
at Qlik.NPrinting.Rest.Client.Api.UsersApi.UsersPostWithHttpInfo(UserRequest userRequest) in C:\Users\kahe\Documents\src\nprinting-adsync\src\NPrintingRestClient\Api\UsersApi.cs:line 2173
at Qlik.NPrinting.Rest.Client.Api.UsersApi.UsersPost(UserRequest userRequest) in C:\Users\kahe\Documents\src\nprinting-adsync\src\NPrintingRestClient\Api\UsersApi.cs:line 2115
at Example.Example.Main() in C:\Users\kahe\Documents\Visual Studio 2017\Projects\Connect2NPrinting\Connect2NPrinting\Program.cs:line 104

Environment

Operating system where the nprinting-adsync is deployed

Windows 10 & .Net 4.7.1

NPrinting

Windows Server 2012R2 Standard, 4 cores 16GB ram

Versions

  • nprinting-adsync: latest according to git
  • NPrinting: November 2017
  • Operating system: Client Windows 10, Server Windows Server 2012R2 Standard, 4 cores 16GB ram

When I set the field Domainaccount to "" in the code example everything works as it is supposed to. But I need the domainaccount set to enable Windows login in NPrinting.

NPrinting Swagger Codegen

I want create a similar rest library for python. I wonder if you could provide me with your swagger.json file that you used to generate the library. Or comment on where I can find the specification of swagger.json.

Thanks in advanced.

ADSync to NPrinting if no E-mail information in AD

Description

Is there a way to sync AD to NPrinting if email information is not available in AD?

Steps done

  1. Configure the adsyncnprinting config file.
  2. Build the batch file.
  3. Run the ADSyncDemoApp.exe file in command prompt.
  4. Restarting NPrinting Services.
  5. AD is not sync to NPrinting User.

Attached are the screenshots on the steps above.
Note: AD do not have email information required by NPrinting.

Operating system where the nprinting-adsync is deployed

Windows Server 2012

NPrinting

NPrinting Server February release
build
config
exefile
get-ad
refreshing_webconsole
restarting_services

no users imported

The application ends with a success message:

Performing an incremental sync.
Incremental sync successfully done.

but no user is imported in NPrinting.
I don't receive any error message so I'm not sure where to search for further information. Is there a way to know if NPrinting connection of ADSync is working and to check the users found in AD by ADSync ?

Versions

  • NPrinting: 17.6
  • Operating system: windows 2008 R2 Dataserver

EDIT:
I forced a full sync and i've got this as further response:

Processing Group: NPtest_Users

so ADSync is actually connected correctly to AD but then I get an error posting to nprinting:

API Error: Qlik.NPrinting.Rest.Client.Client.ApiException: Error calling UsersPo
st: {"error":{"code":400,"message":"Malformed parameters"}}
   at Qlik.NPrinting.Rest.Client.Api.UsersApi.UsersPostWithHttpInfo(UserRequest
userRequest)
   at ADSyncCSharp.Service.NpUserService.AddNewNpUser(User adUser)
   at ADSyncCSharp.Processor.ActiveDirectoryProcessor.HandleNPrintingUser(User u
ser)
   at ADSyncCSharp.Processor.ActiveDirectoryProcessor.ProcessNew(IList`1 entry)
   at ADSyncCSharp.Service.FullSyncOperation.execute(String querySearchFilter, I
EntryProcessor`1 entryProcessor)
   at ADSyncCSharp.Service.ActiveDirectorySyncService.FullSync()
   at ADSyncDemoApp.Component.AdSync.Sync()
   at ADSyncDemoApp.Program.Main(String[] args)

EDIT 2 [SOLVED]
I replaced the domain account which is optional in nprinting with an empty string and ADSync worked.
The replacement took place in NpUserService.cs on row 80.
The domain account string which was generating the malformed parameter exception contained a double backslash: domain\\nptest.user1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.