示例#1
0
        private static void MergeAndSavePeopleLists(Dictionary <string, ImportExportRecord> list)
        {
            foreach (var person in list)
            {
                if (!PeopleList.ContainsKey(person.Value.Upn))
                {
                    // add them
                    PeopleList[person.Value.Upn] = person.Value;
                }
                else
                {
                    // else update their photo location
                    PeopleList[person.Value.Upn].PhotoLocation = person.Value.PhotoLocation;
                }
            }

            SaveManifest(PeopleList);
        }
示例#2
0
        private static void ImportToActiveDirectory(bool promptForUsersToImport)
        {
            try
            {
                Logger.Debug($"Starting import to AD");

                var testUser = string.Empty;

                if (promptForUsersToImport)
                {
                    WriteToConsole($"Upn for test user to import [e.g. [email protected]]: ");
                    testUser = ReadFromConsole();
                }

                WriteToConsole($"Active Directory domain contoller [e.g. 192.168.1.10, or domaincontroller.contoso.com]: ");
                var dc = ReadFromConsole();

                WriteToConsole($"Administrator username [e.g. administrator]: ");
                var username = ReadFromConsole();

                WriteToConsole($"Administrator password: "******"Account domain [e.g. CORP]: ");
                var domain = ReadFromConsole();

                Logger.Debug($"Domain controller: {dc}");
                Logger.Debug($"Username: {username}");
                Logger.Debug($"Domain: {domain}");

                var settings = new AdSettings()
                {
                    AdServer      = dc,
                    AdCredentials = new AdConnectionCredentials(username, password, domain)
                };

                Logger.Debug($"Initializing AD worker");

                var worker = new AdWorker(settings);

                if (promptForUsersToImport)
                {
                    if (!PeopleList.ContainsKey(testUser))
                    {
                        WriteToConsole($"Test user specified not found in user list.");
                    }
                    else
                    {
                        // make a small list
                        var testList = new Dictionary <string, ImportExportRecord>();
                        testList[testUser] = PeopleList[testUser];

                        // just import the test list
                        worker.ImportPicsToAd(testList);
                    }
                }
                else
                {
                    worker.ImportPicsToAd(PeopleList);
                }

                WriteToConsole();
                WriteToConsole($"Completed import of photos to AD. Press any key to return to main menu.");
                ReadFromConsole();
            }
            catch (Exception e)
            {
                WriteToConsole($"Problem importing: {e.Message}");
                WriteToConsole("Press any key to continue");
                var input = ReadFromConsole();
            }
        }