Skip to main content

Creating User ON AD (Active Directory) by C# programming.


Introduction
Microsoft’s Active Directory aka AD is used to manage user, computer and other resources on Domain Cotroller. There are many tools available for managing Active Directory. When it comes to deal with Active directory its headache for many programmers.  There are plenty of sample code available on Microsoft’s MSDN foum.
Technical
Working with Active directory one has be concern about Network Security, business Rule and Technological constraints. If you are accessing your Active Directory through ASP.Net /MVC Web Application, then you must be sure about the permission at IIS level and Domain Controller Level.
For Accessing Active directory protocol used is known as LDAP(Lightweight Directory Access Protocol). Microsoft Provides methods to deal with LDAP in System.DirectoryServices assembly.
In  DirectoryServices Assembly a class named DirectoryEntry  used to access Active Directory. This class inherits Component class.
By creating instance of this class we create pointer to all directory entries. Constructor of this class take LDAP Url,credential and Authentication Type as arguments as shown bellow:


DirectoryEntry MailFolder = new DirectoryEntry(LDAPPath,”username”, “password”, AuthenticationTypes.Secure);


Here authenticationType enum does have following values

  • Anonymous
  • Delegation
  • Encryption
  • Fastbind
  • None
  • ReadOnlyServer
  • Sealing
  • Secure
  • SecureSocketssLayer

We have chosen here to have Secure AuthenticationType.

Parameter “LDAPPath”: This will be the Ldap Url that points to your active directory
For ex. LDAP://myDc.myServer.net:389/DC=myServer,DC=net

Parameter “Username”: This will be the username that have access to Active Directory.
Parameter “Password”: Password for supplied username.



Comments

Popular posts from this blog

Accessing Enum in template–Angular with Typescript

By reading title of  this post, It  seems some what misleading. In Angular 2 (or higher version for that matter). We cannot directly access  Enum or any other type for that matter into template. so, for an example  consider following example now if we try to access Enum WeekDays in HTML template as follows It would be resulted in runtime error shown below To resolve this error we should be assigning enum to component property as shown below. Reason behind this is , Component is the execution context for an Angular application. We can reference only those properties in template which are defined in component or have scope in component.

Setting up Visual Studio code for Java Spring boot development

  Download Visual Studio Code to your machine by clicking here . You will be redirected to official download site for VS Code. You can download VS depending on your OS. When we open VS Code and click on explorer (Ctrl+Shft+E). There two options available by default. Open Folder Clone Repository Visual Studio code is an Editor not a full fledged IDE. But we can configure VS Code by installing relevant extensions available at  https://marketplace.visualstudio.com/vscode . To install extension directly from Visual Studio, click on Extension icon on Menu item at left panel. Alternatively we can use Ctrl+Shft+X keyboard short cut. First extension we going to search is "Extension Pack From Java" from Microsoft. This extension pack is collection of extensions which is needed to enabled Java development in General. Language Support for Java - Rad Hat Debugger for Java - Microsoft Maven for Java - Microsoft Test Runner for Java - Microsoft Project Manager for Java - Microsoft. Next ex...

Improve website performance - Javascript Memoization

Memoization What is Memoization? Memoization is a technique used in programming to write optimizied code. This is very useful in use cases when the system is performing very CPU intensive tasks repeatedly. What are the use Cases for Memoization? Memoization can be useful when the system is performing same task again and again like API output caching - This is not recommended though as it requires a cache invalidation mechanism which is tricky to implement. Calling a recursive function e.g. Fibonacci series. One thing to note here is, memoization works well in case of pure function only. What is a Pure function ? A function which produces the same output for the same given input every time. Lets understand this with the Fibonacci series example. Below program is written without memoization where result of previously executed function is not cached. So each time the program calls the Fibonacci function, it calculates results every time. Now, below is the improved memoized version o...