Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Thu Mar 26, 2009 6:27 am Post subject: Develop a context menu extension for an Active Directory object |
|
|
To develop a context menu extension for an Active Directory object:
- Create a new context menu extension using the 'New Project' wizard to create a new project or the 'Add New Item...' wizard to add a new context menu extension to an existing project.
- Since the context menu extension is not targeted at any file extension or ProgID, remove all TargetExtension attributes that may be applied to the extension class (which is derived from the ContextMenuExtension class).
- Add your menu items in the OnGetMenuItems method overridden method.
- Register the extension on the system using the RegisterExtension.exe (or RegisterExtensionDotNet20.exe) utility.
- Now, you need to register the extension with Active Directory. To do so, start ADSIEdit.msc and navigate to the following path:
CN=user-Display,CN=409,CN=DisplaySpecifiers,CN=Configuration,DC=ssware,DC=com
In the above path, replace ssware.com with your own domain and substitute 'user-Display' with whatever type of object you want to register the extension for.
- Double-click on 'CN=user-Display' entry in the right-hand listview to bring up its 'Properties' dialog.
- In the 'Attributes' list box, select the 'adminContextMenu' or the 'shellContextMenu' entry and click the 'Edit' button to bring up the 'String Editor' dialog
- In the 'String Editor' dialog, add the following line:
"4,{GUID OF YOUR CONTEXT MENU EXTENSION CLASS}"
Example : "4,{B084EEB5-C144-4006-A7C3-8DB4ED46C54B}"
The GUID of your context menu extension class is the same GUID that is applied to your class using the Guid attribute.
If there is already an entry with position of '4', then you can specify the highest position not yet specified.
- Now your context menu extension is registered with Active Directory. You can now test this by using the 'Active Directory Users and Computers' and browsing to a user and right-clicking on a user. You will see the menu items added by your extension.
- To determine the objects (users/computers/etc) that are right-clicked, you can override the OnInitializeEx method and use the Utils.GetDSOBJECTFromDataObject and Utils.GetDSDISPLAYSPECOPTIONSFromDataObject method as follows:
protected override bool OnInitializeEx(IOleDataObject dataObject)
{
DSOBJECT[] dsObjects = Utils.GetDSOBJECTFromDataObject(dataObject);
foreach (DSOBJECT d in dsObjects)
{
System.Diagnostics.Debug.WriteLine(d.name);
}
DSDISPLAYSPECOPTIONS options = Utils.GetDSDISPLAYSPECOPTIONSFromDataObject(dataObject);
return true;
}
|
|