同步联系人信息

在此方法中,将从CSV文件(可能是LDAP提取或任何其他来源)中提取的个人详细信息与iTop同步。

名称:如何从LDAP动态人员

类型:如何

听众:管理员, 集成, 开发者 

水平:中间

持续时间:1h

关键词:数据同步, 集成 

iTop版本:2.2.0

状态:例

先决条件

您将需要:

  • 知道如何从LDAP服务器中提取有关某人的信息并将此信息保存到.CSV文件中
  • 拥有一个iTop系统(已安装演示数据),并可以访问管理员账号
  • 知道如何使用命令行连接到iTop Web服务器

该教程的目的

在此教程中,您将学习如何:

  • 创建并配置同步数据源,以将一类对象同步到iTop中
  • 将外部数据馈入同步并将动态馈入此同步数据源
  • 了解同步状况报告

Synchronizing Persons from a CSV file

分步说明

初始配置

在这里,您将创建同步数据源。

管理工具菜单中,单击同步数据源。

Synchronization Data Sources menu

击“创建新的同步数据源”。

Synchronization Data Sources menu

在以下屏幕中,在适当的字段中输入名称(来自LDAP的人员),目标类别(人员)和用户(管理员)。

Synchronization Data Sources menu

单击创建按钮以创建数据源。

Synchronization Data Sources menu

创建数据源后,单击右上角的“修改”并编辑“属性”选项卡,如下所示:

Synchronization Data Sources menu

在浏览器的URL中,记下同步数据源对象的标识符。 (显示对象时在URL中查找&id = xxx)。

第一次同步:初始负载

然后在iTop根目录下的目录“数据”中创建文本文件“ persons.csv”,其内容如下:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Manager;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No

在iTop根目录的命令行中,启动以下命令:

chro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

调整参数:

  • auth_user:您的iTop登录名
  • auth_pwd:您的iTop密码
  • data_source_id:上面创建的同步数据源的标识符

预期的输出:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 228
#Data Lines: 2
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 2
#Updated (before synchro): 0
#Synchronization---
#------------------
#Replicas: 2
#Replicas touched since last synchro: 2
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 0
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 2 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

检查同步数据源的状况(如果需要,请按“刷新”图标)

https://www.itophub.io/wiki/media?w=500&tok=8c5200&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto3.png

您会看到2个人已更新。

导航到联系人“ Claude Monet”的详细信息,您可以看到此对象现在已同步:

https://www.itophub.io/wiki/media?w=500&tok=0fb12e&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto4.png

查看“历史记录”标签,了解最近的更改:

https://www.itophub.io/wiki/media?w=500&tok=6a07c2&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto6.png

如果尝试修改Person,则可以看到其大多数属性已锁定:

https://www.itophub.io/wiki/media?w=500&tok=6da5b2&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto5.png

第二次同步:更新联系人

将文件“ persons.csv”修改为变更,将Claude Monet的职能从“经理”修改为“著名画家”。在iTop根目录下的目录数据中修改文本文件“ persons.csv”,内容如下:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No

使用相同的命令启动导入并再次同步:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

输出如下:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 235
#Data Lines: 2
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 0
#Updated (before synchro): 2
#Synchronization---
#------------------
#Replicas: 2
#Replicas touched since last synchro: 2
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 0
#Objects updated: 1 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

同步的输出指出仅更新了1个对象。也可以在同步数据的状况选项卡上查看来源:

然后导航至“ Claude Monet”人员的详细信息:

https://www.itophub.io/wiki/media?w=500&tok=75e334&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto5_famous_painter.png

第三次同步:创建一个新的联系人

接下来,通过在末尾添加一行来修改iTop根目录下数据目录中的文本文件“ persons.csv”:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No

使用相同的命令启动导入并再次同步:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

输出如下:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 294
#Data Lines: 3
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 1
#Updated (before synchro): 2
#Synchronization---
#------------------
#Replicas: 3
#Replicas touched since last synchro: 3
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 1 (0 warnings)
#Objects creation errors: 0
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

同步的输出表示仅更新了1个对象。也可以在同步数据的状况选项卡上查看来源:

https://www.itophub.io/wiki/media?w=500&tok=634031&media=2_7_0%3Aadvancedtopics%3Astatus_updated_replicas3.png

使用页面左上方的全局搜索,将“联系人:Piet”用于搜索,然后单击搜索的名称以显示其详细信息。

https://www.itophub.io/wiki/media?w=500&tok=dd7c90&media=2_7_0%3Aadvancedtopics%3Anew_contact_piet_mondrian.png

第四次同步:以错误为例

然后在iTop根目录下的目录“数据”中修改文本文件“ persons.csv”,方法是在末尾再添加一行:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No
4;Klimt;Gurstav;Test;gustav.klimt@demo.com;Active;;+335566778899;No

使用相同的命令启动导入并再次同步:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

输出如下:

#Load--------------
#------------------
#Data Source: 5
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 361
#Data Lines: 4
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 1
#Updated (before synchro): 3
#Synchronization---
#------------------
#Replicas: 4
#Replicas touched since last synchro: 4
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 1
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

同步的输出指出存在一个错误

在此处添加错误中副本详细信息的屏幕截图

https://www.itophub.io/wiki/media?w=500&tok=6a3a10&media=2_7_0%3Aadvancedtopics%3Astatus_error_1_error.png

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No
4;Klimt;Gurstav;Demo;gustav.klimt@demo.com;Active;;+335566778899;No

使用相同的命令启动导入并再次同步:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

应该没有错误,并且在演示组织中创建了联系人Gustav Klimt。

原贴链接:https://www.itophub.io/wiki/page?id=2_7_0%3Aadvancedtopics%3Asynchro_howto_personsfromldap


Data Synchronization: How to synchronize a Persons from a CSV file

In this How to, a person's details extracted from a CSV file (which might be an LDAP extract or any other source), will be synchronized with iTop.

name:
How to synchronize Persons from LDAP
type:
How To
audience:
AdministratorIntegratorDeveloper
level:
Intermediate
duration:
1h
keyword:
Data SynchroIntegration
iTop version:
2.2.0
state:
example

Prerequisites

What you will need to:

  • Know how to extract information about a person from your LDAP server and save this information to a .CSV file

  • Have an iTop system (with the demo data installed), with access to an admin account

  • Know how to connect to your iTop web server using the command line

Aim of this tutorial

In this tutorial, you will learn how to:

  • Create and configure a Synchro Data Source for synchronizing one class of objects into iTop

  • Feed and synchronize the external data into this Synchro Data Source

  • Understand the synchronization status report

Synchronizing Persons from a CSV file

Step by step instructions

Initial configuration

Here, you will create the Synchro Data Source.

In the Admin tools menu, click on Synchronization Data Sources

Synchronization Data Sources menu

Click on Create a new Synchro Data Source.

Synchronization Data Sources menu

In the following screen, enter the Name (Persons from LDAP), Target class (Person) and User (admin) in the appropriate fields.

Synchronization Data Sources menu

Click on the Create button to create the Data Source.

Synchronization Data Sources menu

Once the Data Source has been created, click on Modify in the top right corner and edit the Attributes tab as shown below:

Synchronization Data Sources menu

In the URL of your browser, note down the identifier of the Synchro Data Source object. (Look for &id=xxx in the URL when displaying the object).

First synchronization: initial load

Then create the text file “persons.csv” in the directory “data” under the root of iTop, with the following content:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Manager;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No

From command line in the iTop root directory, launch the following command:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

Adjust the parameters:

  • auth_user: your iTop login

  • auth_pwd: your iTop password

  • data_source_id: the identifier of the Synchro Data Source created above

Expected output:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 228
#Data Lines: 2
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 2
#Updated (before synchro): 0
#Synchronization---
#------------------
#Replicas: 2
#Replicas touched since last synchro: 2
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 0
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 2 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

Check the status of the Synchro Data Source (press the “Refresh” icon if needed)

https://www.itophub.io/wiki/media?w=500&tok=8c5200&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto3.png

You can see that 2 Persons were updated.

Navigate to the details of the contact “Claude Monet”, you can see that this object is now synchronized:

https://www.itophub.io/wiki/media?w=500&tok=0fb12e&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto4.png

Check the “History tab” for recent changes:

https://www.itophub.io/wiki/media?w=500&tok=6a07c2&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto6.png

If you try to modify the Person, you can see that most of its attributes are locked:

https://www.itophub.io/wiki/media?w=500&tok=6da5b2&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto5.png

Second synchronization: updating a contact

Modify the file “persons.csv” to change the function of Claude Monet from “Manager” to “Famous painter” Modify the text file “persons.csv” in the directory dataunder the root of iTop, with the following content:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No

Launch the import and synchronization again using the same command:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

The output is the following:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 235
#Data Lines: 2
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 0
#Updated (before synchro): 2
#Synchronization---
#------------------
#Replicas: 2
#Replicas touched since last synchro: 2
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 0
#Objects updated: 1 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

the output of the synchro states that only 1 object was updated. This can be viewed also on the status tab of the Synchro Data Source:

Then navigate to the details of the Person “Claude Monet”:

https://www.itophub.io/wiki/media?w=500&tok=75e334&media=2_7_0%3Aadvancedtopics%3Asynchro-data-source-howto5_famous_painter.png

Third synchronization: creating a new contact

Next, modify the text file “persons.csv” in the directory data under the root of iTop, by adding one line at the end:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No

Launch the import and synchronization again using the same command:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

The output is the following:

#Load--------------
#------------------
#Data Source: 1
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 294
#Data Lines: 3
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 1
#Updated (before synchro): 2
#Synchronization---
#------------------
#Replicas: 3
#Replicas touched since last synchro: 3
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 1 (0 warnings)
#Objects creation errors: 0
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

The output of the synchro states that only 1 object was updated. This can be also viewed on the Status tab of the Synchro Data Source:

https://www.itophub.io/wiki/media?w=500&tok=634031&media=2_7_0%3Aadvancedtopics%3Astatus_updated_replicas3.png

Use the global search at the top-left of the page to search for “Contact:Piet”, then click on the name of the object to display its details.

https://www.itophub.io/wiki/media?w=500&tok=dd7c90&media=2_7_0%3Aadvancedtopics%3Anew_contact_piet_mondrian.png

Fourth synchronization: a case of error

Then modify the text file “persons.csv” in the directory “data” under the root of iTop, by adding one more line at the end:

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No
4;Klimt;Gurstav;Test;gustav.klimt@demo.com;Active;;+335566778899;No

Launch the import and synchronization again using the same command:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

The output is the following:

#Load--------------
#------------------
#Data Source: 5
#Synchronize: 1
#Class: Person
#Separator: ;
#Qualifier: "
#Charset Encoding:UTF-8
#Date format: <none>
#Data Size: 361
#Data Lines: 4
#Columns: primary_key, name, first_name, org_id, email, status, function, phone, notify
#Output format: summary
#Simulate: 0
#Change tracking comment: 
#Issues (before synchro): 0
#Created (before synchro): 1
#Updated (before synchro): 3
#Synchronization---
#------------------
#Replicas: 4
#Replicas touched since last synchro: 4
#Objects deleted: 0
#Objects deletion errors: 0
#Objects obsoleted: 0
#Objects obsolescence errors: 0
#Objects created: 0 (0 warnings)
#Objects creation errors: 1
#Objects updated: 0 (0 warnings)
#Objects update errors: 0
#Objects reconciled (updated): 0 (0 warnings)
#Objects reconciled (unchanged): 0 (0 warnings)
#Objects reconciliation errors: 0
#Replica disappeared, no action taken: 0

the output of the synchro states that there is one error

Here add screenshot of the details of the replica in error

https://www.itophub.io/wiki/media?w=500&tok=6a3a10&media=2_7_0%3Aadvancedtopics%3Astatus_error_1_error.png

Then modify the text file “persons.csv” in the directory “data” under the root of iTop, by fixing the last line at the end (replace Test by Demo):

persons.csv
 
primary_key;name;first_name;org_id;email;status;function;phone;notify
1;Monet;Claude;Demo;claude.monet@demo.com;Active;Famous painter;+33123456789;Yes
2;Flaubert;Gustave;IT Department;gustave.flaubert@demo.com;Active;;+33987654321;No
3;Mondrian;Piet;Demo;p.m@demo.com;Active;;+334433221100;No
4;Klimt;Gurstav;Demo;gustav.klimt@demo.com;Active;;+335566778899;No

Launch the import and synchronization again using the same command:

php synchro/synchro_import.php --auth_user=admin --auth_pwd=admin --csvfile=./data/persons.csv --data_source_id=1 --output=summary

There should be no error and the contact Gustav Klimt is created in the Demo organization.

标签:
由 superadmin 在 2020/08/27, 16:21 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司