📜 ⬆️ ⬇️

How does friendship begin with Active Directory

I often have to deal with the processing of information from Active Directory. Since this system is widely distributed in many places, I decided to share my experience with it.

It all started with the fact that I was distributing access to MS Sharepoint. In the applications from employees, at best, the accounts came in, at worst they could write something like “Me and my boss”. At first, it strained, and I, feeling like a real admin, sent such requests back to careless users, so that they would redo everything. It turned into a pile of angry letters and calls. I even began to wonder if it was not by chance that the abbreviation from Active Directory - AD coincided with the Russian word “Hell”. In the end, realizing that we need to change the world for the better, I decided to sort out in detail what is generally stored in Active Directory and how it can be used to automatically distribute access and other useful things.

The company employee information is stored in 2 places:

Uniqueness is maintained in Oracle, and access is given via AD, i.e. one employee may have multiple accounts. There was a need to uniquely identify the employee for his account.
')
The solution to this problem was found and replicated in many utilities and software products actively used within the company. One of the most widely used utilities is the employee information search program. It searches for an employee or employees by various criteria and provides the most complete information about them, combining data from Active Directory and Oracle. Particularly popular are photos of employees that are stored in a database.

It is also worth noting the integration of Active Directory not only with Oracle but also with MS Sharepoint. Thanks to the solution found, an application appeared that was able to quickly give access to a group of users from Active Directory to the pages of the Sharepoint portal, and also to remove from it users who, for various reasons, left it.

The problem was solved in 2 ways:
  1. For information on one employee - DBMS_LDAP in Oracle
  2. In order to download all available records and see what the Active Directory is in general, we used C # code

When using C #, consider the following (System.DirectoryServices.dll):

There is also a DirectorySearcher.SizeLimit property, which sets the maximum number of records in the returned result. By default, it is 0, which means to take this value from the server. The server usually has a value of 1000. You can play with the SizeLimit property and see how the result of the function changes ( link ).

The link above has an example of code that uses yiled, which is more correct from the point of view of .NET operation, but in the example below I did not use it, for clarity of the algorithm.

Code examples:



Conclusion:


The ability to work with Active Directory and access it directly from the Oracle database has greatly simplified the work of the programmers of the department where I work. Initially, for the sake of experiment, I downloaded the contents of Active Directory into a database table. Then, to my surprise, I discovered a number of stored procedures that worked with this table. It turned out that the developers turned to it, too lazy to understand the package DBMS_LDAP. This precedent led me to the desire to tell and give examples of how to work with Active Directory.

Source: https://habr.com/ru/post/238075/


All Articles