How to: Create Password Extensions in C#
This topic describes how to create a password extension using C# and Microsoft Visual Studio 2008. To create a password extension project, you must copy the Microsoft.MetadirectoryServices assembly to your development system and manually create a reference to the assembly. You can find the assembly in the bin\assemblies folder of the Forefront Identity Manager Synchronization Service (FIM Synchronization Service) program folder. The default folder is %ProgramFiles%\Microsoft Forefront Identity Management\2010\Synchronization Service\bin\assemblies\.
To create a password extension using Visual Studio 2008, you must complete the following steps:
Create a new C# class library project.
Add a reference to the Microsoft.MetadirectoryServices assembly.
Implement the interfaces.
Build the class library.
Install the password extension in the extensions folder. (Optional)
To create a new C# class library project using Visual Studio 2008
Click Start, point to All Programs, and then click Microsoft Visual Studio 2008.
The Visual Studio 2008 development environment appears.
On the File menu, point to New, and then click Project.
In the New Project dialog box, under Project Types, click Visual C#.
On the Templates menu, click Class Library.
In the Name box, type the name of the rules extension that you are creating, and then click Browse.
Browse to the location where you want to store the project files, click Open, and then click OK. The name of the new project now appears in Solution Explorer.
To add a reference to the Microsoft.MetadirectoryServices assembly
On the Project menu in Visual Studio 2008, click Add Reference.
In the .NET tab of the Add Reference dialog box, click Microsoft.MetadirectoryServices, and then click OK. If the file does not appear in the Component Name list, click the Browse tab. Browse to the folder that contains the assembly file, click Microsoft.MetadirectoryServices, and then click Open.
Click OK to close the Add Reference dialog box.
In Solution Explorer, Microsoft.MetadirectoryServices now appears as one of the references.
To implement the interfaces
Add
using Microsoft.MetadirectoryServices;
to the declarations section above the namespace in your source code.Change
Class1
to the name of your class by adding: IMAPasswordManagement
. For example, if the name of your class is Sample_Password_Class, the class declaration ispublic class Sample_Password_Class : IMAPasswordManagement
.Add the following code to implement the IMAPasswordManagement interface.
public void BeginConnectionToServer(String connectTo, string user, string password ) { // TODO: Remove this throw statement if you implement this method. } public void ChangePassword(CSEntry csentry, string OldPassword, string NewPassword ) { // TODO: Remove this throw statement if you implement this method. } public void EndConnectionToServer() { // TODO: Remove this throw statement if you implement this method. } public ConnectionSecurityLevel GetConnectionSecurityLevel() { // TODO: Remove this throw statement if you implement this method. } public void RequireChangePasswordOnNextLogin(CSEntry csentry, boolean fRequireChangePasswordOnNextLogin ) { // TODO: Remove this throw statement if you implement this method. } public void SetPassword(CSEntry csentry, string NewPassword ) { // TODO: Remove this throw statement if you implement this method. }
To build the class library
On the Build menu, click Build Solution.
If you receive the following message, the password extension was successfully built:
------ Build started: Project: Password Extension, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... Building satellite assemblies... ---------------------- Done ---------------------- Build: 1 succeeded, 0 failed, 0 skipped
The password extension file, which has a .dll extension, is in the bin\Debug folder of your project folder.
Before you use the password extension, install the file in the extensions folder. The default folder for password extensions is %ProgramFiles%\Microsoft Forefront Identity Management\2010\Synchronization Service\Extensions.
The following procedure is optional. You can set Visual Studio 2008 to install the password extension automatically in the extensions folder as part of the build process, as follows.
To install the password extension in the extensions folder
In Solution Explorer, click your class library project.
On the View menu, click Property Pages.
There are two folders in the Property Pages dialog box: Common Properties and Configuration Properties.
Open the Configuration Properties folder. In the Configuration drop-down list, click All Configurations.
In the left pane of the Property Pages dialog box, click Build.
In the Output Path box, type the name of the rules extensions folder, or browse to the location of the rules extensions folder. The default folder for rules extensions is %ProgramFiles%\Microsoft Forefront Identity Management\2010\Synchronization Service\Extensions.
See Also
Concepts
How to: Create Password Extensions
Best Practices for Password Extensions
How to: Implement Password Extensions