Method, system, device and medium for synchronizing a contact list
By monitoring address book changes on the collaborative office platform through a synchronization server, and utilizing protocol conversion middleware and hash value comparison, the problem of low synchronization efficiency between the collaborative office platform and the LDAP server address book was solved, achieving efficient and accurate automatic synchronization and ensuring data consistency.
Patent Information
- Application Number
- CN202510409191.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-04-02
AI Technical Summary
In existing technologies, the synchronization of address books between collaborative office platforms and LDAP servers is inefficient, error-prone, and difficult to guarantee the real-time performance and consistency of data.
By monitoring address book changes on the collaborative office platform through a synchronization server, obtaining and comparing the address book of the LDAP server, using protocol conversion middleware to solve protocol incompatibility issues, combining the token bucket algorithm to control the request rate, using hash value comparison to determine differences, and setting up retry mechanisms and logging during the synchronization process, automatic synchronization is achieved.
It improves synchronization speed and accuracy, ensuring that the address book of the collaborative office platform is consistent with that of the LDAP server, reducing the risk of manual intervention and data loss.
Smart Images

Figure CN120263892B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, in particular to a method, system, device and medium for synchronizing address books. BACKGROUND
[0002] By synchronizing the address book of an LDAP (Lightweight Directory Access Protocol) server with the address book of a collaborative office platform (such as Feishu, WeChat for Enterprise, and DingTalk, etc.), unified user management and identity authentication can be achieved. In related technologies, it is common to manually add or modify departments and users one by one in the collaborative office platform to synchronize the internal organization structure of an enterprise with the address book of the collaborative office platform. However, this method is inefficient, error-prone, and difficult to ensure real-time and consistency of data. Therefore, there is an urgent need for an efficient and accurate method for synchronizing address books to solve the above problems. SUMMARY
[0003] In view of the above problems, the present application is proposed to provide a method, system, device and medium for synchronizing address books to overcome the above problems or at least partially solve the above problems.
[0004] To achieve the above object and other related objects, the present application provides a method for synchronizing address books, applied to a synchronization server connected to an LDAP server and a collaborative office platform, comprising:
[0005] When a change in the first address book of the collaborative office platform is detected, the first address book is obtained from the collaborative office platform, and the second address book is obtained from the LDAP server, and the user information in the first address book is compared with the user information in the second address book to determine the address book difference information between the first address book and the second address book;
[0006] According to the address book difference information, the second address book is updated synchronously to keep the first address book consistent with the second address book.
[0007] Optionally, before the steps of obtaining the first address book from the collaborative office platform and obtaining the second address book from the LDAP server when a change in the first address book of the collaborative office platform is detected, the method further comprises:
[0008] An SSL / TLS connection with the LDAP server is established using the preconfigured connection parameters in the synchronization server, and the LDAP server is authenticated.
[0009] Optionally, after the step of establishing the SSL / TLS connection with the LDAP server by using the preconfigured connection parameter in the synchronization server and authenticating the LDAP server, the method further comprises:
[0010] setting a timing task to periodically poll and query the second address book of the LDAP server to obtain a query result;
[0011] extracting user attributes of the query result and converting the user attributes into data in a serialized format;
[0012] comparing the data in the serialized format with historical data of the second address book cached by the synchronization server to obtain user difference information of the second address book.
[0013] Optionally, before the steps of listening to a change in the first address book of the collaborative office platform, obtaining the first address book from the collaborative office platform, and obtaining the second address book from the LDAP server, the method further comprises:
[0014] registering and logging in to an open platform of the collaborative office platform, creating an address book API on the open platform, and obtaining an identifier and a secret key of the address book API;
[0015] applying for a permission of the address book API, configuring application data permission of the address book API, and setting a white list of the address book API;
[0016] calling the address book API by using the identifier and the secret key.
[0017] Optionally, the step of comparing user information in the first address book with user information in the second address book to determine address book difference information of the first address book and the second address book comprises:
[0018] hashing user attributes of each user in the first address book to generate a first hash value of each user in the first address book, and hashing user attributes of each user in the second address book to generate a second hash value of each user in the second address book;
[0019] comparing the first hash value with the second hash value to determine the address book difference information of the first address book and the second address book.
[0020] Optionally, after the step of synchronously updating the second address book according to the address book difference information to keep the first address book consistent with the second address book, the method further comprises:
[0021] When the step of synchronously updating the second address book according to the address book difference information fails, the step of synchronously updating the second address book according to the address book difference information is executed again after waiting for a preset time, and when the number of failures reaches a preset number, failure information is recorded and the address book difference information is saved.
[0022] Optionally, after the step of synchronously updating the second address book according to the address book difference information so as to keep the first address book consistent with the second address book, the method further comprises:
[0023] generating a synchronization log of the step of synchronously updating the second address book according to the address book difference information, and recording the synchronization log of each synchronization updating operation by using a change log.
[0024] In a second aspect, the present application further provides a system for synchronizing address books, applied to a synchronization server, wherein the synchronization server is connected to an LDAP server and a collaborative office platform, and the system comprises:
[0025] a comparison module, configured to acquire a first address book from the collaborative office platform and a second address book from the LDAP server when the first address book of the collaborative office platform is found to have changed, and compare user information in the first address book with user information in the second address book to determine address book difference information of the first address book and the second address book;
[0026] a synchronization module, configured to synchronously update the second address book according to the address book difference information so as to keep the first address book consistent with the second address book.
[0027] In a third aspect, the present application provides an electronic device, comprising a memory and a processor, wherein the memory is configured to store a computer program, and the processor is configured to execute the computer program stored in the memory, so that the electronic device executes the steps of the method for synchronizing address books.
[0028] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the program is executed by an electronic device to implement the steps of the method for synchronizing address books.
[0029] The above one or more technical solutions provided by the present application can have the following advantages or at least achieve the following technical effects:
[0030] The method, system, device and medium for synchronizing the address book, when the first address book of the collaborative office platform is changed, the first address book of the collaborative office platform is compared with the second address book of the LDAP server, and the address book difference information obtained by comparison is synchronized and updated into the second address book, so that the first address book in the collaborative office platform and the second address book in the LDAP server are automatically synchronized, and the synchronization rate and accuracy are further improved. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 A flowchart of a method for synchronizing an address book is shown as an embodiment of the present application;
[0032] Figure 2 A functional module diagram of a system for synchronizing an address book is shown as an embodiment of the present application;
[0033] Figure 3 A schematic diagram of an electronic device is shown as an embodiment of the present application. DETAILED DESCRIPTION
[0034] The embodiments of the present application will be described in detail with specific reference to the drawings. The skilled person can easily understand other advantages and effects of the present application from the content disclosed in the specification. The present application can also be implemented or applied in other different embodiments, and the details in the specification can be modified or changed in different ways without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0035] It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present application in a schematic manner, and the diagrams only show the components related to the present application, not the number, shape and size of the components when actually implemented. The actual implementation of each component may be randomly changed in terms of type, number and proportion, and the layout pattern of the components may also be more complex.
[0036] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application, however, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details, and in other embodiments, the known structures and devices are shown in the form of block diagrams rather than in detail, to avoid making the embodiments of the present application difficult to understand.
[0037] The terms "first", "second", and the like in the description and claims of the present disclosure and the above drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described herein can be implemented. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion.
[0038] Unless otherwise specified, the term "a plurality" means two or more.
[0039] In the present disclosure, the character " / " represents a "or" relationship between the objects before and after it. For example, A / B means: A or B.
[0040] The term "and / or" is a description of the relationship between the objects, which means that there can be three relationships. For example, A and / or B means: A or B, or, A and B, three relationships.
[0041] In order to facilitate understanding, the related terms or terms used in the embodiments of the present application will be explained first as follows:
[0042] <1>, LDAP (Lightweight Directory Access Protocol) is a directory service protocol based on X.500 standard, used to access and maintain distributed directory information services.
[0043] <2>, SSL / TLS (Secure Sockets Layer / Transport Layer Security) is a security protocol used to provide encryption, authentication and data integrity in network communication.
[0044] <3>, API (Application Programming Interface) is an interface that allows different software programs to interact.
[0045] <4>, go-ldap, a library for operating LDAP servers in Go language, provides a set of functions and structures that allow developers to easily interact with LDAP servers, perform operations such as query, add, modify and delete.
[0046] <5>, Web hook, a mechanism that allows an application to send real-time notifications to another application when a specific event occurs. For example, when a specific event occurs in application A (such as creating, deleting, modifying users, etc.), application A will automatically trigger Webhook.
[0047] <6>、RESTful (Representational State Transfer-full), an architectural style based on HTTP protocol, is used to design web applications. It makes the system more modular, scalable and easy to maintain through principles such as uniform interface, stateless interaction, resource orientation and hypermedia link.
[0048] <7>、SCIM (System for Cross-domain Identity Management), an open standard, aims to simplify the management of users and groups, especially in multi-tenant or cross-organizational environments. SCIM provides a standardized method for managing identity information (such as users, groups, etc.), enabling efficient synchronization and management of identity data between different systems.
[0049] <8>、Node.js, an open-source, cross-platform JavaScript runtime environment based on Chrome V8 engine, allows developers to run JavaScript on the server side. It is designed for high-performance, high-concurrency web applications, using an event-driven, non-blocking I / O model to efficiently handle a large number of concurrent connections.
[0050] <9>、Apache Camel, an open-source integration framework, simplifies the development of message passing and integration between applications. It allows developers to define routing and mediation rules through simple Java DSL (Domain Specific Language) or XML configuration, enabling data exchange and business process orchestration between different systems.
[0051] <10>、Nginx+Lua, a technology that enhances the functionality of Nginx by embedding Lua scripts into it without relying on external applications.
[0052] <11>、Dedicated DN, a name in LDAP that uniquely identifies an entry in the directory.
[0053] <12>、VLV index (Virtual List View Index), a technology used to optimize the performance of LDAP server queries. By virtualizing the entries in the directory as an ordered list, and through an indexing mechanism, quickly locate and retrieve entries.
[0054] <13>、Range query, a technique for requesting data segments from the server, allowing clients to segment resources or data.
[0055] <14> Rabbit MQ, an open-source message broker that supports multiple messaging patterns, including point-to-point, publish / subscribe, and request / response. It is suitable for task queues, microservice communication, and event-driven architectures.
[0056] <15> Kafka, a distributed stream processing platform, primarily used for building real-time data pipelines and stream processing applications. It is suitable for log aggregation, real-time analytics, event sourcing, and IoT data processing.
[0057] <16> ELK (Elasticsearch, Logstash, Kibana), a log analysis and visualization platform composed of Elasticsearch, Logstash, and Kibana, widely used for collecting, processing, storing, and visualizing log data.
[0058] <17> Loki, a log aggregation system developed by Grafana Labs, designed for large-scale log data.
[0059] The technical solutions in the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0060] Please refer to Figure 1 An embodiment of the present application provides a method for synchronizing address books, applied to a synchronization server connected to an LDAP server and a collaborative office platform. The method can include the following steps S10-S20:
[0061] Step S10, when a change in a first address book of the collaborative office platform is detected, obtaining the first address book from the collaborative office platform and obtaining a second address book from the LDAP server, and comparing user information in the first address book with user information in the second address book to determine address book difference information between the first address book and the second address book.
[0062] The synchronization server is used to connect the collaborative work platform and the LDAP server to synchronize the address books of the LDAP server and the collaborative work platform. It can use the LDAP protocol to directly read the address book of the LDAP server (such as using the go-ldap library to connect the LDAP server, querying and obtaining user and department information in the LDAP server, such as name, email, mobile phone number, etc.), or based on protocol conversion middleware to obtain the address book stored and managed by the LDAP server; and the synchronization server can call the address book API of the collaborative work platform to obtain the address book stored and managed by the collaborative work platform.
[0063] The first address book is used to represent the address book (i.e., enterprise organization structure) stored and managed in the collaborative office platform, which includes enterprise department information and enterprise personnel (i.e., user) information, etc.
[0064] The user can represent a member in the enterprise. The user resource of the address book contains basic information such as unique identification (ID), name, phone number, and mailbox, and also contains information such as the department to which the user belongs and custom fields.
[0065] The department is used to represent a node on the enterprise organization structure tree. In the department, users can be added as department members, and new departments can be added to establish parent-child hierarchical relationships.
[0066] The second address book is used to represent the address book managed and stored in the LDAP server.
[0067] The address book difference information is used to represent the address book difference obtained by comparing the first address book and the second address book. It can include creating, modifying (such as phone number, mailbox, department, etc.), and deleting departments and users.
[0068] As an example, when the first address book includes employee A (sales department), employee B (technical department), and employee C (marketing department), and the second address book includes employee A (sales department), employee B (technical department), and employee C (sales department), the first address book and the second address book are compared, and it is found that the department of employee C in the first address book has changed.
[0069] As another example, when the first address book includes employee A, employee B, and employee D, and the second address book includes employee A, employee B, and employee C, the first address book and the second address book are compared, and it is found that employee D is added and employee C is deleted in the first address book.
[0070] In a specific implementation, when the first address book of the collaborative work platform changes, the first address book change event (such as employee onboarding, employee offboarding, employee information modification, etc.) pushed by the collaborative office platform can be received through the Webhook configured by the address book API of the collaborative work platform. The synchronization server can request to call the address book API of the collaborative work platform to obtain the first address book, and the synchronization server can request to obtain the second address book from the LDAP server; then, the user information in the first address book is compared with the user information in the second address book, and the address book difference information of the first address book and the second address book is obtained.
[0071] Preferably, considering that LDAP is based on a directory service protocol (tree query), while the collaborative office platform usually uses a REST ful API or SCIM interface, protocol incompatibility will cause data interaction difficulties. In addition, the collaborative office platform API has limitations (such as call frequency, page size, etc.), and the interface specifications of different platforms need to be adapted (for example, the page number of Feishu is not the same as that of Dingding).
[0072] Therefore, the embodiments of the present application convert LDAP operations into HTTP requests or inversely parse API responses into LDAP entries based on a protocol conversion middleware, to overcome the data interaction difficulties caused by protocol incompatibility. In addition, for the problem of API frequency control limitation of the collaborative office platform, the embodiments of the present application control the request rate by a token bucket algorithm and combine an exponential backoff mechanism to deal with the frequency limitation problem.
[0073] Exemplarily, the process of converting LDAP operations into HTTP requests or inversely parsing API responses into LDAP entries based on the protocol conversion middleware can include:
[0074] Firstly, a protocol conversion middleware capable of supporting both LDAP protocol and HTTP protocol is deployed, and mapping rules between LDAP operations and HTTP requests are configured in the protocol conversion middleware. The protocol conversion middleware has the ability to parse and generate data of both protocols, for example, it can be a Node.js custom middleware, an Apache Camel middleware, an Nginx+Lua middleware, etc. The mapping rules between LDAP operations and HTTP requests, for example, which HTTP request method (such as GET) corresponds to the LDAP query operation, which attributes of LDAP are mapped into the parameters in the HTTP request, and how the API response data corresponds to the fields of the LDAP entry, etc.
[0075] Secondly, in response to an LDAP operation request, the protocol conversion middleware captures the request and converts the LDAP operation information into the corresponding HTTP request format according to the pre-configured mapping rules and sends it to the target system. The target system, for example, a Web application, aims to realize the conversion of LDAP operations to HTTP requests, solving the interaction problem between the LDAP system and the system that only supports HTTP protocol.
[0076] Finally, when the target system returns an API response after processing the HTTP request, the protocol conversion middleware receives the response, and according to the pre-configured mapping rule, the data in the API response is parsed and converted into an LDAP entry format. In this way, even if the target system returns an HTTP format response, it can be correctly converted into an entry that the LDAP system can recognize and process, thereby completing the entire data interaction process and overcoming the difficulty of data interaction caused by protocol incompatibility.
[0077] Exemplarily, the request rate is controlled by the token bucket algorithm, and the exponential backoff mechanism is combined to deal with the frequency limiting problem. The process can include:
[0078] First, tokens are put into the token bucket at a fixed rate, and only requests that obtain tokens will be processed when there are requests. For example, 10 tokens can be put into the bucket per second, and each request consumes 1 token, so the request rate can be limited to 10 requests per second.
[0079] Secondly, when the request is rejected due to flow limiting (such as the frequency of synchronizing server requesting to call the address book API of the collaborative work platform to obtain the first address book exceeding the limit, or the frequency of requesting to call the address book API of the collaborative work platform to synchronize and update the first address book exceeding the limit), the exponential backoff mechanism is triggered for retry. After each request is rejected, the waiting time is exponentially increased before the next attempt. For example, the first retry waits for 1 second, the second retry waits for 2 seconds, the third retry waits for 4 seconds, and so on, until success or the maximum number of retries (or maximum waiting time) is reached. This strategy can effectively reduce the pressure on the address book API of the collaborative work platform by dynamically adjusting the retry interval, and avoid further flow limiting due to frequent requests.
[0080] Step S20, synchronously updating the second address book according to the address book difference information, so that the first address book and the second address book are consistent.
[0081] In a specific implementation, after obtaining the address book difference information of the first address book and the second address book, the synchronization server can request to synchronize and update the second address book of the LDAP server according to the address book difference information, so as to realize synchronization of the address book of the LDAP server and the address book of the collaborative work platform. Thus, when a change in the first address book of the collaborative work platform is detected, the first address book of the collaborative work platform and the second address book of the LDAP server are compared, and the comparison result is synchronized to the second address book as address book difference information, so as to realize automatic synchronization of the first address book in the collaborative work platform and the second address book in the LDAP server, and further improve the synchronization rate and accuracy.
[0082] As an example, when the first address book includes employee A (sales department), employee B (technical department), and employee C (marketing department), and the second address book includes employee A (sales department), employee B (technical department), and employee C (sales department), the first address book and the second address book are compared, and it is found that the department of employee C in the first address book has changed. The department information of employee C in the second address book can be modified (such as modifying the sales department of employee C in the second address book to the marketing department), so as to ensure that the updated second address book is the same as the first address book.
[0083] As another example, when the first address book includes employee A, employee B, and employee D, and the second address book includes employee A, employee B, and employee C, the first address book and the second address book are compared, and it is found that employee D is added and employee C is deleted in the first address book. Further, employee C in the second address book can be deleted, and employee D can be added in the second address book, so as to ensure that the updated second address book is the same as the first address book.
[0084] Further, in an embodiment, before step S10, the method can further include step A10:
[0085] Step A10, establishing an SSL / TLS connection with the LDAP server by using the preconfigured connection parameters in the synchronization server, and authenticating the LDAP server.
[0086] The connection parameters are used to represent the necessary configuration information for establishing and managing the communication between the synchronization server and the LDAP server, such as server address, port number, special DN (unique identifier), encryption method (SSL / TLS encryption), etc.
[0087] In this embodiment, before synchronizing the address book, it is necessary to establish a communication connection between the LDAP server and the synchronization server, such as connecting to the LDAP server using the LDAP library of Go language (such as go-ldap library), and then querying the department and user information in the LDAP server; the connection parameters of the LDAP server, such as the network address of the LDAP server, the port number, the special DN, and the encryption method, can be preconfigured and managed in the synchronization server, and then the preconfigured connection parameters are used to establish an SSL / TLS connection with the LDAP server; then, the Bind method (such as simple binding, anonymous binding) is used to authenticate the LDAP server, that is, the synchronization server can verify the user identity through the binding operation. After completing the identity verification, the synchronization server can obtain the address book data in the LDAP server according to its permission; thereby successfully establishing the connection between the LDAP server and the synchronization server, and laying a foundation for subsequent address book synchronization.
[0088] As an example, in the simple bind mode, the user provides a dedicated DN (unique identifier) and password for authentication. The synchronization server sends a bind request containing the DN and password to the LDAP server. The LDAP server checks the existence of the dedicated DN and verifies the password. If the verification is successful, the LDAP server returns a success response. If the verification fails, the LDAP server returns an error message.
[0089] As another example, in the anonymous bind mode, the synchronization server does not provide any identity information (i.e., does not provide a username and password) when binding, allowing access to the publicly accessible part of the data in the LDAP server. The synchronization server sends a bind request to the LDAP server, where the dedicated DN and password fields are empty. After receiving the bind request, the LDAP server checks whether anonymous access is allowed. If the LDAP server is configured to allow anonymous binding, the request is accepted and a success response is returned. Otherwise, the request is rejected and an error message is returned.
[0090] Preferably, the embodiments of the present application take into account the performance degradation of LDAP queries when synchronizing tens of thousands of users (e.g., deep paging query page Size = 1000 causes timeout), and solve the problem by optimizing the paging mechanism, parallel processing of data blocks, caching, and asynchronous preloading through VLV / Range queries.
[0091] First, create a VLV index in the LDAP server (e.g., Open LDAP) to allow the client to directly locate the data block through the offset and range, or to optimize the paging mechanism through the Range query. In this way, it is possible to avoid traversing all entries and reduce the traversal overhead when deep paging, and the query time is optimized from linear growth to constant time. VLV query is a high-efficiency paging query method that avoids the performance problem caused by large offset in traditional paging query through virtual list. Range query reduces the amount of data queried by specifying the query range, thereby improving the query efficiency. These two query methods can effectively solve the problem of performance degradation of LDAP queries, especially when deep paging query is performed, which can significantly reduce the query time.
[0092] Second, according to the memory and processing capacity of the LDAP server, the data to be synchronized is divided into multiple small data blocks; and the multi-threading or multi-processing technology is used to process the divided data blocks in parallel. In this way, the computing resources of the LDAP server can be fully utilized, the data processing speed can be improved, and the synchronization time can be reduced.
[0093] Finally, for frequently queried data, a cache mechanism is used to store it in memory to reduce the number of queries to the LDAP server. At the same time, through the way of asynchronous preloading, the data that may be needed is loaded in advance when the LDAP server is idle. In this way, the response speed of the LDAP server can be further improved, and the user waiting time can be reduced.
[0094] Further, in an embodiment, after step S20, the method can further include step S30:
[0095] Step S30, when the step of synchronously updating the second address book according to the address book difference information fails, waiting for a preset time, and then executing the step of synchronously updating the second address book according to the address book difference information again, when the number of failures reaches a preset number, recording the failure information, and saving the address book difference information.
[0096] Wherein, the preset time is used to represent the waiting time set in advance according to the reason of synchronous updating failure.
[0097] The preset number is used to represent the number of retries set in advance (such as the preset number of retries is 3 times).
[0098] In this embodiment, when no response is received from the LDAP server within a certain time, it can be determined that the step of synchronously updating the second address book according to the address book difference information fails (such as network interruption of the LDAP server, business failure, etc.); this synchronous updating task can be stored in the message queue of the synchronization server (such as storing the synchronous updating failure task in the Rabbit MQ or Kafka queue of the synchronization server), and the step of synchronously updating the second address book according to the address book difference information is executed again after a period of time; and when it is detected that the number of synchronous updating operation failures exceeds the preset number, an artificial alarm is triggered (such as through the robot or email notification of the collaborative work platform), and then the failed synchronous updating operation (i.e. synchronous updating failure information) can be recorded in the log (including failure reason, timestamp, etc.), and the address book difference information of this synchronous updating operation is saved. Thus, by setting the retry strategy, the stability and reliability of the synchronization server are improved, the data loss caused by synchronization failure is reduced, and the problem of synchronous updating failure is effectively handled.
[0099] Further, in an embodiment, after step S20, the method can further include S40:
[0100] Step S40, generating a synchronization log of synchronously updating the second address book according to the address book difference information, and recording the synchronization log of each synchronous updating operation by using the change log.
[0101] Wherein, the synchronization log is used to represent a file or a data set recording various information in the process of the synchronization server performing the synchronization update operation; it includes but is not limited to: basic information, state information and data information. It uses a structured format (such as JSON), including operation type, user ID, error details.
[0102] Basic information: can include timestamp, operation type (such as incremental synchronization), synchronization source and target (such as synchronization from the first address book to the second address book).
[0103] State information: can include synchronization status (success, failure, in progress, etc.), error code and description (such as when synchronization fails, record specific error code and detailed error description).
[0104] Data information: can include the amount of data synchronized (such as several employee information, department information), data change details (for incremental synchronization, record which data has changed, such as adding, modifying or deleting which department or user).
[0105] In the embodiment, after each execution of the step of synchronously updating the second address book according to the address book difference information, the corresponding synchronization log is generated, and the synchronization log of each synchronization update operation is recorded by using the change log; thus, by reasonably recording, storing and managing the synchronization log, log analysis solutions such as ELK or Loki analysis are facilitated.
[0106] In the embodiment, when the change of the first address book of the collaborative office platform is listened to, the first address book of the collaborative work platform is compared with the second address book of the LDAP server, and the address book difference information obtained by comparison is synchronously updated into the second address book, so that the first address book in the collaborative office platform and the second address book in the LDAP server are automatically synchronized, and the synchronization rate and accuracy are further improved.
[0107] Based on the foregoing embodiment, a second embodiment of the method for synchronizing address books is proposed, in which, after step A10, the method can further include steps A20-A40 as follows:
[0108] Step A20, a timing task is set to periodically poll the second address book of the LDAP server to obtain a query result.
[0109] Wherein, the timing task is used to represent a task of querying the latest second address book of the LDAP server initiated by the synchronization server periodically, which will be automatically executed at a specific time interval or a specific time point (such as once every 5 minutes).
[0110] The query result is used to represent the user attributes (such as user ID, mailbox, department, etc.) of the latest second directory of the LDAP server obtained after the timing task is executed.
[0111] In a specific implementation, after the connection between the LDAP server and the synchronization server is successfully established, the LDAP server can be periodically polled by setting a timing task, such as using an LDAP query statement to specify a search base (Base DN) and a filter condition, so as to periodically obtain the latest second directory from the LDAP server and obtain a user list (such as returning user attributes, such as mailbox, mobile phone number, etc.) that meets the requirements, that is, the query result.
[0112] It should be noted that in the process of polling the second directory of the LDAP server by the synchronization server (such as the go-ldap library), the accounts marked as invalid or expired in the LDAP server are filtered out.
[0113] Step A30, extracts the user attributes of the query result and converts them into serialized format data.
[0114] The serialized format data is used to represent the user attributes extracted from the query result converted into a unified data structure (such as JSON or Protobuf).
[0115] In a specific implementation, the query result can be parsed to extract user attributes from the query result, and then the user attributes can be converted into serialized format data in a unified format.
[0116] Step A40, compare the serialized format data with the second directory history data cached by the synchronization server to obtain user difference information of the second directory.
[0117] The second directory history data is used to represent the second directory in a unified data structure (such as JSON or Protobuf) cached by the synchronization server after the last synchronization update operation.
[0118] The user difference information is used to represent the department or user information of the second directory in the LDAP server that has changed since the last synchronization operation, that is, the newly added, modified, or deleted department and user information found after comparing the serialized format data of the latest second directory with the second directory history data.
[0119] In a specific implementation, the data in the serialized format can be compared with the second directory history data cached in the synchronization server, and the departments or users added, modified or deleted in the second directory of the LDAP server can be marked, and then the user difference information of the second directory can be obtained; thus, the user difference information can be taken as the input of the synchronization update, the first directory of the collaborative work platform is synchronized and updated, so as to determine that the user and department information in the second directory of the LDAP server is consistent with the first directory of the collaborative work platform.
[0120] In the embodiment, the second directory of the LDAP server is periodically polled by setting a timing task, and the query result is obtained; the user attribute of the query result is extracted and converted into data in a serialized format; the data in the serialized format is compared with the historical second directory data in the synchronization server, and the user difference information of the second directory is obtained. Thus, the latest user and department information is obtained by periodically querying the LDAP server, the first directory of the collaborative work platform is synchronized and updated, and the consistency of the second directory of the LDAP server and the first directory data of the collaborative work platform is maintained.
[0121] Based on the foregoing embodiment, a third embodiment of the synchronization directory method of the present application is provided. In the embodiment, before step S10, the method can further include the following steps B10-B30.
[0122] Step B10, after registering and logging in the open platform developer background of the collaborative work platform, a directory API is created on the open platform, and the identifier and secret key of the directory API are obtained.
[0123] The identifier (app_id) and the secret key (app_secret) are used to represent the unique identifier and secret key of the open platform application, and are used to call the API of the open platform.
[0124] In a specific implementation, a developer account can be registered and a password corresponding to the developer account can be set in the open platform of the collaborative work platform, and then the developer account and the password are used to log in the open platform; after logging in the open platform, an "application creation" button can be clicked, and then an application name (such as a directory API) and an application description are filled in, and then a creation is clicked; after the creation of the directory API is completed, the identifier (app_id) and the secret key (app_secret) of the directory API can be viewed in the application detail page.
[0125] Step B20, the permission of the directory API is applied, the application data permission of the directory API is configured, and the white list of the directory API is set.
[0126] The permission range of the address book API defines the department and user data range that the application can access, and the application cannot access data outside the permission range.
[0127] The application data permission is used to indicate the address book data range (such as the data range of departments and users that can be accessed) that the application can obtain when calling the address book API in the application identity. Only the departments and users within the data permission range, the application can query or operate.
[0128] The configuration method of the address book data permission, by default, the address book permission range is configured to be consistent with the available range of the application; manual configuration can select specific departments or members and set them as the address book permission range; and the all-member range can be configured as the address book permission of all members in the enterprise.
[0129] As an example, when calling the address book API to query the information of user A in the application identity, the application needs to have the data permission of user A.
[0130] As another example, there are three departments A, B, and C in the address book. If an application only has the address book permission of departments B and C, the application can only obtain the data of departments B and C in the address book through the interface, and an error of no permission will be reported when obtaining the data of department A.
[0131] In a specific implementation, the (development configuration) permission management page in the developer background of the development platform can be entered to select and confirm the API permissions required by the address book API, such as the permissions of creating, deleting, and modifying departments and users, reading the department information list, user information, and the like. Then, the application data permission of the address book API can be configured in the address book permission range area. In order to improve the security of application access, the IP white list function can be used to set the IP list that can legally access the address book API of the collaborative work platform. The request of the IP address not in the white list will be rejected, and an error prompt information will be returned.
[0132] Step B30, calling the address book API by using the application access credential.
[0133] In a specific implementation, the address book API can be called only after the creation of the address book API, the application of the API permission, the configuration of the application data permission, and the setting of the IP white list. After logging in to the open platform of the collaborative work platform, the collaborative work platform can be requested to authorize access to the data in the address book API, and an authorization code can be obtained after the authorization of the collaborative work platform. Then, the app_id, the app_secret, and the authorization code of the address book API can be used to obtain the user_access_token interface through the OAuth2.0 process. The user_access_token (i.e., the access credential returned after the authorization) can be used to call the address book API in the user identity.
[0134] It should be noted that the access token user_access_token is obtained through the POST / authen / v1 / access_token interface, and a token automatic refreshing mechanism is set. The obtained user_access_token has a validity period (e.g., is used within 3 minutes after the generation of the authorization code). The validity period of the user_access_token needs to be checked regularly to ensure that the token is refreshed before expiration.
[0135] In the embodiment, the open platform of the collaborative work platform is registered and logged in, the address book API is created on the open platform, and the identification and secret key of the address book API are obtained. The permission of the address book API is applied, the application data permission of the address book API is configured, and the white list of the address book API is set. The address book API is called by using the identification and secret key. Thus, the address book API of the collaborative work platform is safely and efficiently called, and a foundation is laid for subsequent address book synchronization.
[0136] Based on the foregoing embodiment, a fourth embodiment of the method for synchronizing an address book is provided. In the fourth embodiment, step S10 can further include the following sub-steps S101-S102.
[0137] In sub-step S101, the user attributes of each user in the first address book are hashed to generate first hash values of each user in the first address book, and the user attributes of each user in the second address book are hashed to generate second hash values of each user in the second address book.
[0138] The user attributes refer to a collection of basic information and extended information of a user in an address book, which is used to describe various characteristics of an employee of an enterprise. The basic attributes can include, but are not limited to, a user ID, a name, an email address, a mobile phone number, a gender, a department, and the like. The extended information can include, but is not limited to, a job level, a sequence, a personnel type, a custom field, and the like.
[0139] a first hash value, used to represent a hash value generated by using a user attribute of each user in the first address book.
[0140] a second hash value, used to represent a hash value generated by using a user attribute of each user in the second address book.
[0141] In a specific implementation, the user attribute (such as name, email address, and mobile phone number) of each user in the first address book can be obtained first, and then the user attribute of each user is spliced, and a hash algorithm (such as MD5, SHA256, etc.) is used to process the spliced user attribute, to generate a first hash value of each user in the first address book; and the user attribute of each user in the second address book can be obtained, and then the user attribute of each user is spliced, and a hash algorithm (such as MD5, SHA256, etc.) is used to process the spliced user attribute, to generate a second hash value of each user in the second address book.
[0142] As an example, the user attribute of user A, such as name, email address, and mobile phone number, can be obtained from the first address book; and then the name, email address, and mobile phone number of user A are spliced, and a hash algorithm is used to process the spliced user attribute, to generate a hash value of user A.
[0143] In sub-step S102, the first hash value is compared with the second hash value, and address book difference information of the first address book and the second address book is determined.
[0144] In a specific implementation, after obtaining the first hash value of each user in the first address book and the second hash value of each user in the second address book, the first hash value and the second hash value can be compared bit by bit through (XOR operation), and when it is detected that the first hash value and the second hash value are different, the difference between the first hash value and the second hash value (i.e., the address book difference information of the first address book and the second address book) is obtained. If the first hash value and the second hash value are different, it indicates that the department information and / or user information in the first address book and the second address book are also different (inconsistent). If the first hash value and the second hash value are consistent, it indicates that the first address book and the second address book are not modified; thus, by comparing the hash values, repeated data can be quickly identified, and repeated submission can be avoided.
[0145] In the embodiment, the user attributes of each user in the first address book are hashed to generate first hash values of each user in the first address book, and the user attributes of each user in the second address book are hashed to generate second hash values of each user in the second address book; the first hash values are compared with the second hash values to determine address book difference information of the first address book and the second address book; thus, by comparing the hash values, it can be determined whether the first address book and the second address book are the same, and the data security is further improved.
[0146] Based on the same inventive concept, the fifth embodiment of the present application also provides a system for synchronizing address books corresponding to the method for synchronizing address books in the foregoing embodiments. Since the system in the fifth embodiment of the present application has a similar principle for solving problems as the method for synchronizing address books in the foregoing embodiments of the present application, the implementation of the system can be referred to the implementation of the method, and the repeated parts will not be described herein.
[0147] Please refer to Figure 2 , the system for synchronizing address books of the present application can include:
[0148] The acquisition module 10 is configured to acquire the first address book from the collaborative office platform and the second address book from the LDAP server when the first address book of the collaborative office platform is found to be changed, and compare the user information in the first address book with the user information in the second address book to determine address book difference information of the first address book and the second address book.
[0149] The comparison module 20 is configured to update the second address book according to the address book difference information to keep the first address book consistent with the second address book.
[0150] In addition, the present application also provides a computer readable storage medium having a computer program stored thereon, which is executed by a processor to implement the method for synchronizing address books.
[0151] Figure 3 is a schematic block diagram of an electronic device provided by the embodiment of the present application. As shown in Figure 3 , the electronic device includes at least one processor 401, a memory 402, at least one network interface 403 and a user interface 405. Each component in the electronic device is coupled together through a bus system 404. It can be understood that the bus system 404 is used to realize the connection and communication between the components. In addition to the data bus, the bus system 404 also includes a power bus, a control bus and a status signal bus. However, for the purpose of clear illustration, all kinds of buses are marked as the bus system in Figure 3 .
[0152] The user interface 405 can include a display, a keyboard, a mouse, a trackball, a click gun, a key, a button, a touchpad, a touch screen, etc.
[0153] It can be understood that the memory 402 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), which is used as an external cache. By way of example but not limitation, many forms of RAM can be used, such as static random access memory (SRAM), synchronous static random access memory (SSRAM). The memory described in the embodiments of the present application is intended to include but not limited to these and any other suitable category of memory.
[0154] The memory 402 in the embodiments of the present application is used to store various categories of data to support the operation of the electronic device 400. Examples of these data include: any executable programs for operating on the electronic device 400, such as an operating system 4021 and an application program 4022; the operating system 4021 contains various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application program 4022 can contain various application programs, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The method for synchronizing the address book provided by the embodiments of the present application can be included in the application program 4022.
[0155] The method disclosed by the embodiments of the present application can be applied to the processor 401 or implemented by the processor 401. The processor 401 can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the above method can be completed by integrated logic circuits or instructions in the form of software in the processor 401. The processor 401 described above can be a general processor, a digital signal processor (DSP), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 401 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application. The general processor 401 can be a microprocessor or any conventional processor, etc. The steps of the method for synchronizing the address book provided by the embodiments of the present application can be directly embodied as hardware decoding processor execution, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory, and the processor reads the information in the memory to complete the steps of the above method in combination with the hardware thereof.
[0156] In the exemplary embodiments, the electronic device 400 can be one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), or the like for executing the above-described methods.
[0157] In summary, when the first address book of the collaborative office platform is changed, the first address book of the collaborative office platform is compared with the second address book of the LDAP server, and the address book difference information obtained by the comparison is synchronized and updated into the second address book, so that the first address book in the collaborative office platform and the second address book in the LDAP server are automatically synchronized, and the synchronization rate and accuracy are further improved.
[0158] The above-described embodiments only exemplarily illustrate the principles and effects of the present application, and are not used to limit the present application. Any person skilled in the art can modify or change the above-described embodiments without departing from the spirit and scope of the present application. Therefore, all equivalent modifications or changes completed by those skilled in the art without departing from the spirit and technical thought disclosed by the present application should be covered by the claims of the present application.
Claims
1. A method of synchronizing contact lists, the method comprising: The method is applied to a synchronization server connected with an LDAP server and a collaborative office platform, and comprises the following steps: establishing an SSL / TLS connection with the LDAP server by using preconfigured connection parameters in the synchronization server, and authenticating the LDAP server; wherein the connection parameters are used to represent necessary configuration information for establishing and managing communication between the synchronization server and the LDAP server; when a first address book of the collaborative office platform is found to be changed, obtaining the first address book from the collaborative office platform, obtaining a second address book from the LDAP server, comparing user information in the first address book with user information in the second address book, and determining address book difference information of the first address book and the second address book; wherein the comparison of the user information in the first address book with the user information in the second address book to determine the address book difference information of the first address book and the second address book comprises: hash processing of user attributes of each user in the first address book by using a SHA256 algorithm to generate a first hash value of each user in the first address book, and hash processing of user attributes of each user in the second address book by using a SHA256 algorithm to generate a second hash value of each user in the second address book; comparing the first hash value with the second hash value to determine the address book difference information of the first address book and the second address book; synchronously updating the second address book according to the address book difference information, so that the first address book and the second address book are consistent.
2. The method of claim 1, wherein, After the step of establishing an SSL / TLS connection with the LDAP server by using preconfigured connection parameters in the synchronization server, and authenticating the LDAP server, the method further comprises the following steps: setting a timing task to periodically poll and query the second address book of the LDAP server to obtain a query result; extracting user attributes of the query result and converting them into serialized format data; comparing the serialized format data with second address book historical data cached by the synchronization server to obtain user difference information of the second address book.
3. The method of claim 1, wherein, Before the step of, when a first address book of the collaborative office platform is found to be changed, obtaining the first address book from the collaborative office platform, and obtaining a second address book from the LDAP server, the method further comprises the following steps: registering and logging in an open platform of the collaborative office platform, creating an address book API on the open platform, obtaining an identity and a secret key of the address book API; applying for a permission of the address book API, configuring application data permission of the address book API, and setting a white list of the address book API; calling the address book API by using the identity and the secret key.
4. The method of claim 1, wherein, After the step of synchronously updating the second address book according to the address book difference information, so that the first address book and the second address book are consistent, the method further comprises the following steps: When the step of synchronously updating the second address book according to the address book difference information fails, the step of synchronously updating the second address book according to the address book difference information is executed again after waiting for a preset time, and when the number of failures reaches a preset number, failure information is recorded and the address book difference information is saved.
5. The method of claim 1, wherein, The step of synchronously updating the second address book according to the address book difference information further comprises: generating a synchronization log of the step of synchronously updating the second address book according to the address book difference information, and recording the synchronization log of each synchronization updating operation by using a change log.
6. A system for synchronizing address books, characterized by The system is applied to a synchronization server connected with an LDAP server and a collaborative office platform, and comprises: a comparison module configured to establish an SSL / TLS connection with the LDAP server by using a preconfigured connection parameter in the synchronization server, and perform identity authentication on the LDAP server; wherein the connection parameter is used to represent necessary configuration information for establishing and managing communication between the synchronization server and the LDAP server; when a change in a first address book of the collaborative office platform is detected, the first address book is obtained from the collaborative office platform, a second address book is obtained from the LDAP server, and user information in the first address book is compared with user information in the second address book to determine address book difference information between the first address book and the second address book; the comparison module is further configured to perform hash processing on user attributes of each user in the first address book by using a SHA256 algorithm to generate a first hash value of each user in the first address book, and perform hash processing on user attributes of each user in the second address book by using a SHA256 algorithm to generate a second hash value of each user in the second address book; and compare the first hash value with the second hash value to determine the address book difference information between the first address book and the second address book; a synchronization module configured to synchronously update the second address book according to the address book difference information, so that the first address book and the second address book are consistent.
7. An electronic device, comprising: The electronic device comprises a memory and a processor, wherein the memory is configured to store a computer program, and the processor is configured to execute the computer program stored in the memory, so that the electronic device performs the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program is configured to perform the steps of the method according to any one of claims 1 to 5 when executed.
Citation Information
Patent Citations
Method and system for synchronizing data of enterprise address book and personal address book
CN101989989A
Address book automatic generation and query method, and phone
CN103888412A