Welcome to K2 Underground Sign In | Join | Help
Creating a quick AD utilities service object with the Dynamic Assembly Service

David Loomis really outdid himself when he posted the Dynamic Assembly Service to Blackmarket. Within the project location you will find an installer which is basically all that you need to get things rolling.  The Dynamic Assembly Service is a service object that you can use to call methods from any class library dll that you can access on the BP server. 

In my case, I needed the ability to create an AD user.  The out of the box AD service provides many read and list methods with Active Directory, but at the time of this writing doesn't provide everything you would need for handling user on-boarding or off-boarding.

Some time ago, a custom event template called the Active Directory Event Template was written for K2 2003.  While it continues to be a work in progress and the gui looses it's values during an edit (making it difficult to use in a real development scenario), it does generate beautiful AD code which saves us from having to weed through countless lines of horrid AD code available from various sources.  In the case of this example, I opened K2 2003 Studio, ran the Active Directory custom even template, generated my AD code, and copy/pasted into a class library for use by David's service object.  I did have to add/tweak some method arguments and follow them through the code, but spent less than 30 minutes adapting the code to suit my scenario.  (tip:  when running the Active Directory Template you'll be able to click various AD properties and provide either a datafield or plain text to populate them.  I populated each of them with plain text that I could find easily in the code once it was generated.  for example:  for the cn property I used the value  strVariablecn;  for the samaccountname I used the value strVariablesamaccountname -- it was a snap adapting the code to my method by looking for the prefix strVariable everywhere)

Within the attached zip file you will find two visual studio solutions:
-  ADToolsExample contains the class library that I built for a simplistic user creation method.  It takes in several of the possible arguments available when creating a user and returns a boolean value noting the success or failure of the user creation.   In my case I took the compiled dll out of the solution's debug directory and copied it into the "c:\program files\k2 blackpearl\host server\bin" directory.   Then within Workspace > Management Console > SmartObjects > Services, I created a new service instance of the Dynamic Assembly Service and pointed it to the path\filename where the dll now resided.   (tip: You shouldn't have to open this solution or recompile, you should be able to simply copy the dll from the solution's obj/Debug directory to C:\program files\k2 blackpearl\host server\bin )
- ADToolsExample-K2Project contains 2 files:
        1)  A smartobject called CreateADUser.sodx:  This smartobject surfaces the newly created Dynamic Assembly Service ADTools instance's create method.  Note that Service Instance GUIDs are embedded into already created SmartObjects, so you will need to delete/recreate the service method within the included SmartObject before deploying.  If you don't, you will receive a "parent object" error during deployment.
        2)  A test workflow called TestCreateADUser.kprx: This workflow contains one primary activity which essentially runs the SmartObject call to create the AD User.   If the AD user creation fails, the workflow loops back to the client event allowing you to adjust your values.  (**tip:  when you start the process instance - presumably from workspace) you will need to provide the LDAP path in the following format:  LDAP://CN=Users,DC=Denallix,DC=com  substituting Denallix and com for your particular domain) (**another tip: when creating your first user, if you are unsure what cn and samaccountname refer to, add that as a text suffix onto your value, for instance  JosephCN and JosephSAM)

Essentially however, you can probably start from scratch following the general logic of my approach and achieve success within a few hours.  The point here is that with David's Dynamic Assembly Server and Tim's Active Directory Event Template, you have everything you need to create a functioning and tested ActiveDirectory Service Object in very short order.

Published Tuesday, July 29, 2008 4:05 PM by Joseph


Attachment(s): ADToolsExample.zip

Comments

No Comments

Anonymous comments are disabled
Powered by Community Server (Commercial Edition), by Telligent Systems