SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PoepleEditor and want to get some additional informations of a selected user from AD. When PoepoleEditor resolves an Entry you have that PickerEntry as result. One member of it is "key" which i probably should use to find the correct user in AD. I use the DirectorySearcher to search through LDAP. My Problem is that there is no attribute i could use to match the key of PickerEntry. The Value of PickerEntry.Key is "abtestportal\Chris" where the LDAP attribute "distinguishedName" of that user returns "CN=Chris,OU=DOM,DC=ab,DC=testportal". The Problem is that DC contains two strings which are concatenated in the key. Does somebody know how to search?

share|improve this question

I'm not quite sure if I understand you correctly, but I guess you want to extract "abtestportal" from the string "CN=Chris,OU=DOM,DC=ab,DC=testportal".

This could be done with some stringoperations:

    private String GetDcString(String input, String start, String end)
        String result = "";
        while (input.IndexOf(start) > -1)
            input = input.Substring(input.IndexOf(start) + start.Length);
            if (input.IndexOf(end) > 0)
                result += input.Substring(0, input.IndexOf(end));    
                result += input.Substring(0);
        return result;

    private void button1_Click(object sender, EventArgs e)
        String inputstring = "CN=Chris,OU=DOM,DC=ab,DC=testportal";
        String startstring = "DC=";
        String endstring = ",";
        MessageBox.Show(GetDcString(inputstring, startstring, endstring));
        //Messagebox shows "abportal"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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