2

My Idea is to get the list of users for particular project in Tridion Publication using Core Services. I tried to get it from GroupMembershipData. But unfortunatly it is not including Group memberships obtained from an external (LDAP) directory.

So I am trying to get the Group Id using below code. But I am getting Object Reference Null error in the following line :

GroupData group = (GroupData)_client.Read(id, new ReadOptions());             

I understood the ID which I am passing is not correct. Because GroupData is inheriting TrusteeData. So I can't assign the child to Parent. So please help me to get the Publication ID of Group Members and Users for specific project.

protected void UserProjectUserCheck_Click(object sender, EventArgs e)
{
    ICoreService _client = Utility.GetCoreServiceSettings();
    PublicationsFilterData filterData = new PublicationsFilterData();
    var publicationList = _client.GetSystemWideListXml(filterData);
    PopulateProjectSpecificUserList(publicationList);
}

private void PopulateProjectSpecificUserList(XElement publicationList)
{
    string PublicationID = "";
    XmlDocument xmlDoc = new XmlDocument();
    string results = string.Empty;
    IEnumerable<XElement> elementList = publicationList.Elements();
    foreach(XElement elem in elementList)
    {
        if (elem.Attribute("Title").Value.ToString().ToLower().Contains("polo") && elem.Attribute("Title").Value.ToString().Trim().StartsWith("05"))
        {
            PublicationID = elem.Attribute("ID").Value.ToString();
        }
    }
    ICoreService _client = Utility.GetCoreServiceSettings();
    PublicationData pub = (PublicationData)_client.Read(PublicationID, null);

    AccessControlListData t =  pub.AccessControlList;

    string id = string.Empty;       
    foreach(var usrGroups in t.AccessControlEntries)
    {
        id = usrGroups.Trustee.IdRef;
    }           

    GroupData group = (GroupData)_client.Read(id, new ReadOptions());

    var searchDn = ((DirectoryGroupMappingData)group.ClaimMappings.First()).SearchDN;
    var directoryServiceName = ((DirectoryGroupMappingData)group.ClaimMappings.FirstOrDefault()).DirectoryServiceName;
    var result = _client.GetListDirectoryServiceGroupMembers(directoryServiceName, searchDn);

    TridionItemList.DocumentContent = result.ToString();
    TridionItemList.TransformSource = Server.MapPath(@".\ProjectSpecificUserList.xslt"); 
}

1 Answer 1

2

The LDAP group memberships are not in Tridion, so why try to get them out of Tridion? You should query the LDAP server to get this information.

Of course, you'll also probably want to communicate with Tridion to get the information which is there.

4
  • So what is your Conclusion then? Aug 22, 2017 at 13:24
  • That you should query the LDAP server directly Aug 22, 2017 at 14:34
  • 1
    Yes, Dominic is correct, TridionCoreService will get the Tridion Groups not the LDAP Groups Aug 22, 2017 at 15:17
  • Thank you so much @Dominic Cronin and @ Chris Mills. But my aim is to get the Groups from Tridion only. Let see in future may be in web-9 there are giving this future are not. Thank you so much. Will get back to you in future if anything required. Aug 23, 2017 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.