using System; using System.Collections.Generic; using System.Linq; using System.Text; //SharePoint namespace using Microsoft.SharePoint.Client; using System.Net; using EnCryptDecrypt; using System.Configuration; using System.Security.Cryptography; using System.IO; using System.DirectoryServices; using System.DirectoryServices.AccountManagement; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { string key = "a text phrase"; string abc = ConfigurationSettings.AppSettings[0]; string cmc = ConfigurationSettings.AppSettings[1]; // string cmc = "HjMoHs9EMx2NDTdkv4QDUg=="; // string abc = "s1SYwK14I+PvRZBZtWdDw=="; ClientContext clientContext = new ClientContext("http://xxxxxxxx"); NetworkCredential cred = new NetworkCredential(); //string encrypt = encrypt(abc, key); cred.UserName = abc; string decryptedText = CryptorEngine.Decrypt(cmc, key); cred.Password = decryptedText; clientContext.Credentials = cred; List list = clientContext.Web.Lists.GetByTitle("account"); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View/>"; ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(list); clientContext.Load(listItems); clientContext.ExecuteQuery(); foreach (ListItem listItem in listItems) Console.WriteLine("\nTitle: {0}", listItem["Title"]); DirectoryEntry directoryEntry; try { directoryEntry = new DirectoryEntry("LDAP://CN=IT,CN=Users, DC=dev, DC=com"); directoryEntry.RefreshCache(); DirectoryEntry groupContact = new DirectoryEntry("LDAP://CN=,CN=Users, DC=dev, DC=com"); directoryEntry.Properties["member"].Add(groupContact.Properties); directoryEntry.CommitChanges(); } catch (Exception e) { var msg = e.Message.ToString(); throw; } Console.ReadLine(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)