SharePoint Update UserInfo List From AD


namespace UpdateList
{
    class Program
    {
        static void Main(string[] args)
        {
            Program pp = new Program();
            pp.XFunInsert();
        }
        private void XFunInsert()
        {
            using (SPSite oSite = new SPSite("http://localhost:650/sites/lms"))
            {
                using (SPWeb oWeb = oSite.RootWeb)
                {
                  
                    oWeb.AllowUnsafeUpdates = true;
                    using (StreamReader sr = new StreamReader("C:\\Users\\spadmin\\Desktop\\pass.txt"))
                    {
                        String line;
                        List<string> ComputerNames = new List<string>();
                        while ((line = sr.ReadLine()) != null)
                        {
                            try
                            {
                               
                                oWeb.EnsureUser(line);
                               
                                Console.WriteLine(line);
                            }
                            catch
                            {
                           
                            }
                         
                        }
                    }
                    oWeb.AllowUnsafeUpdates = false;
                   
                    
                  
                  
                }


            }
        }
    }
}


Comments

Popular posts from this blog

How to remove app from SharePoint 2013/2016

The model backing the context has changed since the database was created. Consider using Code First Migrations to update the database