Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#
Tip/Trick

Get SIP address from active directory

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
27 Jan 2011CPOL 31.1K   2   2
SIP address from active directory
The below code will be used to get the SIP address from the active directory. SIP address is commonly used in office communicator server. I have used this code to fetch the SIP address. Based on the SIP address, we have applied provisioning on office communicator server 2007.

C#
private string GetSIPAddress(string email)
       {
           DirectoryEntry directoryEntry =
                    new DirectoryEntry(ConfigurationManager.AppSettings["LDAPPATH"]);

           string resultValue = "";

           using (HostingEnvironment.Impersonate())
           {
               DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);
               directorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (mail={0}))", email);

               directorySearcher.PropertiesToLoad.Add("msRTCSIP-PrimaryUserAddress");

               SearchResult result = directorySearcher.FindOne();

               if (result != null)
               {
                   if (result.Properties["msRTCSIP-PrimaryUserAddress"] != null)
                   {
                       resultValue = result.Properties["msRTCSIP-PrimaryUserAddress"][0].ToString();
                       resultValue = "'" + resultValue + "'";
                   }
               }
           };
           return resultValue;
       }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralI have formatted your code for you since you seem too busy t... Pin
Henry Minute27-Jan-11 1:59
Henry Minute27-Jan-11 1:59 
GeneralPlease format your code http://www.codeproject.com/Tips/4207... Pin
Indivara26-Jan-11 23:12
professionalIndivara26-Jan-11 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.