Workflow Soluiton

 View Only
Expand all | Collapse all

Workflow - Can not check if user is in a recursive AD Group

  • 1.  Workflow - Can not check if user is in a recursive AD Group

    Posted Oct 05, 2011 09:31 AM

    Hi there

    I've created a Workflow which should check if the "logged in user" is in a Active Directory group before it continues.
    The members of this AD Group are not only users, but also other groups, therefore it doesn't work properly.


    Example:

    AD Group:
    Windows_IT

    Members:
    - Peter
    - Brian
    - IT_Helpdesk



    AD Group:
    IT_Helpdesk

    Members:
    - Michael
     

    If Michael is logged in and starts the workflow, it will not be able to continue it, because it is not direct in the Group "Windows_IT".

    How can I solve this issue, so that the workflow will check also the Group "IT Helpdesk" that is a member of the Group "Windows_IT"?


    Many thanks in advance

    regards
    Flavio



  • 2.  RE: Workflow - Can not check if user is in a recursive AD Group

    Posted Oct 06, 2011 02:01 AM

    I  think this is only possible, if you write your own dll by using C#
    I had a similar problem with the AD components. I wanted to add our remove Contacts from a specific group, but this wasn't possible with the standard components.

    So I wrote a short C# dll and then it worked!
    There can check if the found group member is a user or a group. If it is a group, you can call you function again..

    Something like this should help, to get all the distinguished Names in the allUsers List:

    DirectoryEntry de = new DirectoryEntry("LDAP://" + ADServer + "/" + searchInThisOU + sDomain, username, password);
    List<string> allUsers = new List<string>();

     

    public static void getEachMember(string groupName)
    {

    DirectorySearcher searchGroup = new DirectorySearcher(de);
    searchGroup.SearchScope = SearchScope.Subtree;
    searchGroup.Filter = "(cn="+ groupName + ")";
    SearchResult resultGroup = searchGroup.FindOne();
    DirectoryEntry group = resultGroup.GetDirectoryEntry();

    // Get Group Member
    foreach (var member in group.Properties["member"])
    {
    DirectoryEntry memberResult = new DirectoryEntry(string.Format("LDAP://{0}", member));
    if (memberResult.Properties["objectCategory"][0].ToString().Contains("CN=Group,"))
    { getEachMember(memberResult.Properties["cn"].ToString()); }
    else
    { allUsers.Add(memberResult.Properties["distinguishedName"].ToString());
    }
    }

     

    I didn't test it, but I think it could work..