Basic concepts of Extension Manager

Source: Internet
Author: User

Basic concepts of Extension Manager

What is Extension Manager?

Extension Manager is a powerful design mechanism provided by Lotus c api. It allows Application designers to register events of interest to the Notes/Domino system, such as em_nsfdbclosesession and em_nsfdbclose. Therefore, you can run your own special plug-in program before or after the kernel operations of Notes/Domino (whether em_reg_before or em_reg_after is used in event registration.

Extension Manager program design specifications

The design framework of the Extension Manager plug-in must comply with certain rules so that it can be called by the notes/Domino System at the right time. For detailed design methods of Extension Manager, refer to the design document released with Lotus c api. Basically, an extension manager plug-in with basic functions should have the following elements:

DLL entry function:
The Extension Manager plug-in must be compiled into executable libraries (for example, Windows dynamic link library DLL or Unix shared object ). The library structure and naming rules are platform-related. For details, see section 2 of the lotus c api user manual, Section 2: "platform-specific naming conventions ". In DLL entry functions, you should create and release plug-in program instances, and cancel the em_xx event registered to the Notes/Domino system before the plug-in program exits.
Plug-in program entry functions
This function is an entry function for customizing plug-in programs. The EM event registration process will be implemented in this function. The function declaration format is as follows:
Status lnpublic mainentrypoint (void );
The name of the entry function can be given at will, but it must be declared as an export function in the module definition file (. Def file) and the export serial number is 1.
Example:
Library nextmngr initinstance
Exports
Mainentrypoint @ 1

 

Before registering a function, we recommend that you use the emcreaterecursionid () function to prevent a plug-in program from being called multiple times.
Plug-in program callback function
This function is the business processing function of the Extension Manager plug-in program. It is responsible for custom processing after receiving the registration event notification.
Extension Manager program running conditions

To run a custom Extension Manager program, you need to do two things:

Place the compiled DLL file in the main directory of Notes/Domino.
Modify the notes. ini file and add a variable as follows:
Extmgr_addins = nextmngr
If there are multiple plug-ins, separate them with commas. If multiple plug-ins have registered the same event, they are processed in sequence according to the registration order of the plug-ins in the notes. ini file.

After learning the basic knowledge above, we will take windows as an example to provide a simple and typical Extension Manager program structure, this example program is only used to describe the program architecture and processing logic of the Extension Manager, and cannot be compiled and run. For details about the Extension Manager example program, see the sample released with the lotus c api.

Extension Manager program structure example

/* Extension Manager program structure example */
/* System header file */
# Include <stdlib. h>
......
/* Notes Domino header file */
# Include <global. h>
......
/* ===== Global variables ===================================== */
Hemregistration hhandler; // context handle of the plug-in program
Emhandler ghandlerproc; // callback function handle of the plug-in program
Word grecursionid; // prevents this program from being called multiple times
Critical_section extends iticalsection; // used for multi-thread synchronization
/* ===== Local function prototyes ==================================== ========= */
Status lnpublic mainentrypoint (void );
// Plug-in program entry function
Status lnpublic emhandlerproc (emrecord far * pexrecord );
// Callback function of the plug-in program
Bool winapi dllmain (hinstance, DWORD fdwreason,
Lpvoid lpreserved); // DLL entry function
/* ===================================================== ============================================= */
Status lnpublic mainentrypoint (void)
{
Status error = noerror;
Error = emcreaterecursionid (& grecursionid );
Error = emregister (em_getpassword, em_reg_before | em_reg_after,
(Emhandler) ghandlerproc, grecursionid, & hhandler );
Return (error );
}
/* ===================================================== ============================================= */
Status lnpublic emhandlerproc (emrecord far * pexrecord)
{
Status error = 0;
Switch (pexrecord-> EID ){
Case em_getpassword:
{
Return (err_bsafe_user_abort );
}
Return Error;
}
/* ===================================================== ============================================= */
Bool winapi dllmain (hinstance, DWORD fdwreason, lpvoid lpreserved)
{
Status error = noerror;
Switch (fdwreason)
{
Case dll_process_attach:
Initializecriticalsection (& receiviticalsection );
Ghandlerproc = (emhandler) makeprocinstance (farproc) emhandlerproc,
Hinstance );
Break;
Case dll_process_detach:
Error = emderegister (hhandler );
Freeprocinstance (ghandlerproc );
Deletecriticalsection (& gcriticalsection );
Break;
}
Return (true );
Unreferenced_parameter (lpreserved );
}

 

 

Back to Top
 

Extension Manager project instance

Next, this article will introduce a project instance of Extension Manager, we hope that this project instance will give some inspiration and guidance to Lotus c api application developers when using Extension Manager to customize applications.

1) engineering background:

To enhance the management of the internal office environment, a customer needs to force users to join a Windows domain. The customer wants to bind the email system for access: restrict users to access the email system only after logging on to the Windows domain.

2) Engineering Design:

To meet customer needs, we can imagine deploying an EM program on the client. The EM program of this client registers the em_getpassword event and checks whether the current Windows user is in the domain before the Password Input dialog box pops up in notes. If the user is not in the domain, err_bsafe_user_abort is returned, which can prevent the Notes client from connecting to the Domino server. For program snippets, see the Extension Manager program structure example.

Everything went smoothly, and it seemed that everything was well done by now. However, it is slow. If you think about it carefully, this solution is not feasible. What if the client does not install this EM program? Or what if the user uninstalled the EM program? In this way, the client can completely bypass the authentication process.

Therefore, we must consider uniform control on the server side, which requires the deployment of an EM program on the server side. The EM program on this server registers the em_secauthentication event and authenticates each user who sends an access request to the mail server in real time. Only when the client logs on to the Windows domain, the server-side EM process enables this user to access the mail server.

The question now is how does the server em program identify whether the client is in the Windows domain? The answer is socket communication method: after relevant judgment, the client em program writes the information of the Notes user to a file on the server where the Domino server is installed (such as info. in dat), the server em program queries this file when authenticating the Access Notes user. If the Access Notes user information is found in info. if the DAT file exists, the user is authorized to access the email server; otherwise, access is denied.

Shows the overall system architecture:

Figure 1 overall system architecture
 

3) Module Design and Implementation

The system is divided into three components:

Notes client em component

Function Description: determines the Windows Domain Information of the current Notes user, sends the information to the Communication Server, and updates the logon time window information after receiving the confirmation information from the communication server. (The time window is a time period. After a Notes client logs on to the Domino server in the domain, it is allowed to access the email server without logging on to the domain)

The algorithm is as follows:

I. Capture em_getpassword messages

Ii. Read the content of the Registry and compare the current time with the time of last registration in the registry to determine whether the time window has expired.

Iii. If the time window has not expired, that is, the Notes client has already registered with the server within a specified period of time, then err_em_continue is returned directly. The control is handed over to notes to allow it to connect to the mail server.

IV. if the time window expires, determine whether the current Windows user is in the domain. If the current Windows user is in the domain, read the IP address and port of the communication server from the registry and send the information of the Notes user, then wait for the response from the server. If you receive a response from the server, update the date table entry in the registry.

V. If the current Windows user is not in the domain, no one has logged on to the Domino server in the domain within the time window, And err_bsafe_user_abort is returned to prevent the notes from connecting to the email server.

Domino server em component

Function Description: capture the Notes user attempting to connect to the current user, read the user information file, and determine whether the current user is a legal user, so as to determine whether to authorize the user to access the mail server.

The algorithm is as follows:

I. register the em_secauthention event

Ii. Obtain the username of the currently applied connection when an event occurs

Iii. query the user information file. If there is information that matches the current user, the user is a legal user, and err_em_continue is returned to give control to the Domino server. Otherwise, err_secure_failed_auth is returned, and the user's connection request is rejected.

Communication Server program

Function Description: reads the username information sent from all clients and stores it in the user information file. For access by EM programs on the Domino server side.

For detailed design and description, see the communication server architecture diagram and its description.

I. Communication Server Architecture Diagram

Figure 2 Communication Server Architecture
 

Ii. Description:

The Communication Server is a multi-threaded concurrent program with four modules:

A) Processing Server Module
Function Description: starts and stops the entire communication server program and records the log information of the entire system.

B) Message Module
Function Description: This module is started by the processing server module. Three threads are started at startup:

Message receiving thread
The thread starts the communication module and waits for messages from the communication module. If the communication module notifies the thread that a message has arrived, it obtains the message and writes it to the receiving message queue.
Message Processing thread
This thread monitors whether there is data in the received message queue in real time. If there is data, this data is taken out and written into the user information file. After the data is successfully written, send a UDP message to the sending message queue. a udp message includes the IP address, port, and confirmation message of a client. It is defined:
Struct udpdata {
Unsigned long ulipaddr;
Unsigned short wport;
String sdata;
};

 

Message sending thread
This thread monitors whether there is data in the sending message queue in real time. If there is data, extract it for analysis, obtain the IP address and port, and then send the data through the communication module.
C) Communication Module
Function Description: This module encapsulates the socket communication API to complete the network communication function.

D) Message Queue Module
Function Description: This module implements the Message Queue function, which is a two-way linked list. The purpose is to cache data and prevent loss of user data. The system has two Message Queues: one is the receiving message queue, which stores the received messages, and the other is the sending message queue, which stores the sent messages.

Summary

Lotus c api is a powerful secondary development tool for notes/Domino, and Extension Manager is an extremely important and complex part of it. Through this project instance, readers can have a certain understanding of this. In the future, we will continue to provide readers with special introductions on Extension Manager.

 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.