I am using following code. let me know any other way
- public async Task
Index() - {
- string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
- string qName = userName.Replace("AMAT\\", "");
- string apiUrl = "http://dca-dev-577/deepika.ldap/api/AD/seachADUsers?searchText="+qName;
- using (HttpClient client = new HttpClient())
- {
- client.BaseAddress = new Uri(apiUrl);
- client.DefaultRequestHeaders.Accept.Clear();
- client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
- HttpResponseMessage response = await client.GetAsync(apiUrl);
- if (response.IsSuccessStatusCode)
- {
- var data = await response.Content.ReadAsStringAsync();
- var table = Newtonsoft.Json.JsonConvert.DeserializeObject
(data); - JArray rss = JArray.Parse(data);
- //JObject rss = JObject.Parse(data);
- string FName = rss[0]["FirstName"].ToString();
- string LName = rss[0]["LastName"].ToString();
- ViewBag.message = "First Name: " + FName + " Last Name: " + LName;
- }
- }
- return View();
- }

Tamal MarickPosted Jun 24, 2019, 2:04 AM
Sivakumar KonetiPosted Jun 24, 2019, 12:19 AM