Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i want to retrieve the birthday and hire date data from active directory,how can i do that?in c# share point 2013

What I have tried:

i want to retrieve the birthday and hire date data from active directory,how can i do that?in c# sharepoint 2013
i tried
Posted
Updated 24-Jun-16 1:17am
Comments
Herman<T>.Instance 21-Jun-16 2:32am    
Is that information set up in AD?
Madhav Gunjal 24-Jun-16 7:18am    
yes

I'm afraid, it's impossible to get birthday and hire date from AD due to limited properties of user[^] in AD.

Please, check this: How to get User Data from the Active Directory[^]
 
Share this answer
 
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
                UserProfileManager profileManager = new UserProfileManager(serviceContext);
                foreach (UserProfile profile in profileManager)
                {
                    var name = profile.DisplayName.ToString();
                    var BirthDateTime = Convert.ToDateTime(profile["SPS-Birthday"].Value).ToLocalTime();
                    var HireDate = Convert.ToDateTime(profile["SPS-HireDate"].Value).ToLocalTime();
                    Console.WriteLine("Name: " + name.ToString());
                    Console.WriteLine("Birthday: " + BirthDateTime);
                    Console.WriteLine("Hire date: " + HireDate);
                }
            }





resolved this by applying above code
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900