Workflow Soluiton

 View Only
  • 1.  Attributes from an Object in non-AD LDAP

    Posted Sep 06, 2013 01:02 AM

    I'm trying to retrieve some specific attributes from objects in a Sun LDAP server.  So its not Microsoft Active Directory which is what most of the existing components seem to be designed for.

    I have used the LDAP component generator to create an LDAPSearch component and that is returning an array of the objects including the distinguished name.  Unfortunately those objects don't seem to come back with any attributes in Workflow.

    Having read a few discussions it looks like I might need to use the Script Generator to get the specific attributes.

    Does anyone have an example of what the script would look like? Or perhaps suggest another way to do this?

    I'm using Workflow 7.1 SP2



  • 2.  RE: Attributes from an Object in non-AD LDAP

    Posted Sep 09, 2013 12:53 AM

    Further to this, I used the script generator and my admittedly wobbly understanding of C# to start trying to get what I need.

    I'm stuck when trying to get the results out though - I get an error message "Since 'Generated.stuff.RunScript()' returns void, a return keyword must not be followed by an object expression" on Compile and close.

    Is is possible to get a return value of type System.DirectoryServices.SearchResultCollection out of a component?  Or perhaps map it to a custom user type?

     

     



  • 3.  RE: Attributes from an Object in non-AD LDAP

    Posted Sep 09, 2013 08:14 AM

    You can't return data with the Script Generator. However, you can return data with the Code (Script) component (in the Scripting lib, not loaded by default)



  • 4.  RE: Attributes from an Object in non-AD LDAP

    Posted Sep 09, 2013 05:41 PM

    Thanks reecardo

    My C# code is returning an array of type System.Directory.Services.SearchResultCollection

    I see thats not available as a Result variable type.

    Is there a way to get this type into the list?



  • 5.  RE: Attributes from an Object in non-AD LDAP

    Posted Sep 11, 2013 10:51 AM

    OK, I'm pretty sure that the only thing that can display in the list are types where Workflow has a datahandler.

    What you can try is the following:

    1. Create a User Defined type integration library that "mirrors" the SearchResultCollection output. Creating this type will also generate a datahandler. Import this integration library into your project.

    2. Select the type you just created as your output. If you don't see the type, try reloading the project.

    3. At the end of your code for the Code(Script) component, after you have your SearchResultCollection, create a new empty list of your user-defined types. Loop through the SearchResultCollection and "map" into a new user-defined type, adding it to the list of types as you go through. Then return the array of user-defined types. Something similar to below (untested):

    //

    List<mytype> types = new List<mytype>();

    foreach(SearchResult blah in mySearchResultCollection)

    {

    mytype t = new mytype();

    t.field1 = blah.field1;

    // etc.

    types.Add(t);

    }

    return types.ToArray();

    EDIT: I think you need to include the namespace of the user-defined comp you created to make this work as well... I haven't tested any of this out, but it's worth a shot.

     



  • 6.  RE: Attributes from an Object in non-AD LDAP

    Posted Sep 11, 2013 04:50 PM

    Awesome response - thanks reecardo!

    I had already created my own user defined type within my workflow and had noticed in the list of available types within the script component.  I was hoping to use a mapping component to convert over to that from the SearchResultCollection.

    I had looked at converting within the script but hadn't quite got my head around the looping I'd need to do within the objects within the SearchResultCollection.  Your example will help I think.

    Much appreciated.