Beispiel #1
0
        // GET: api/AD
        public IEnumerable <string> GetAD(string username)
        {
            AD adCall = new AD();

            string[] results      = new string[2];
            var      searcher     = adCall.GetDirectorySearcher("OU = CriticalMass, DC = cmass, DC = criticalmass, DC = com", "", "");
            var      searchResult = adCall.SearchUserByUserName(searcher, username);

            if (searchResult.GetDirectoryEntry().Properties["mail"].Value != null)
            {
                results[0] = "Email ID : " + searchResult.GetDirectoryEntry().Properties["mail"].Value.ToString();
            }
            if (searchResult.GetDirectoryEntry().Properties["givenName"].Value != null)
            {
                results[1] = "First Name : " + searchResult.GetDirectoryEntry().Properties["givenName"].Value.ToString();
            }
            return(results);
        }