Beispiel #1
0
        public async Task TestUpdateSpecificUser()
        {
            var user = await _client.UserGetAsync(_fixture.TestUserObjectId);

            var postalCodeValue      = DateTime.Now.ToString("yyMMddHHmmss");
            var telephoneNumberValue = DateTime.Now.ToString("ssyyMMddHHmm");
            var changes = new
            {
                PostalCode      = postalCodeValue,
                TelephoneNumber = telephoneNumberValue
            };

            await _client.UserUpdateAsync(user.ObjectId, changes);

            var updatedUser = await _client.UserGetAsync(user.ObjectId);

            Assert.NotNull(updatedUser);
            Assert.Equal(postalCodeValue, updatedUser.PostalCode);
            Assert.Equal(telephoneNumberValue, updatedUser.TelephoneNumber);
        }
Beispiel #2
0
        static async Task TestUpdates()
        {
            var users = await client.UserGetListAsync();

            var user = users.Items[14];

            await client.UserUpdateAsync(user.ObjectId, new
            {
                signInNames = new[] {
                    new SignInName {
                        Value = "*****@*****.**", Type = "emailAddress"
                    }
                }
            });

            user = await client.UserGetAsync(user.ObjectId);
        }
Beispiel #3
0
        static async Task Main(string[] args)
        {
            Console.Write("Checking GraphAPI client credentials...");
            client = new GraphApiClient(applicationId, applicationSecret, tenant);
            await client.EnsureInitAsync();

            var demoEmail = "*****@*****.**";
            var demoUser  = await client.UserGetBySigninNameAsync(demoEmail);

            if (demoUser == null)
            {
                demoUser = await CreateDemoUser(demoEmail, demoEmail.Substring(0, demoEmail.IndexOf("@")));
            }

            await client.UserUpdateAsync(demoUser.ObjectId, new
            {
                passwordProfile = new PasswordProfile
                {
                    EnforceChangePasswordPolicy  = false,
                    ForceChangePasswordNextLogin = true,
                    Password = "******"
                }
            });

            demoUser = await client.UserGetBySigninNameAsync(demoEmail);


            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DONE.");
            Console.ForegroundColor = ConsoleColor.White;

            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            await TestUpdates();

            await DeleteTestUsers();

            // Load local users
            var userRepository = new UserRepository(connectionString);
            var users          = await userRepository.GetUsersAsync();

            // Migrate first 20 user to B2C
            var createdUsers = new List <User>();
            var timespans    = new List <long>();

            foreach (var user in users.Take(20))
            {
                user.DisplayName = "test " + user.DisplayName;
                var sw      = Stopwatch.StartNew();
                var newUser = await client.UserCreateAsync(user);

                var elapsedMs = sw.ElapsedMilliseconds;
                Console.WriteLine($"User added: ({elapsedMs} ms): {user.DisplayName} ({user.SignInNames.First().Value})");
                timespans.Add(elapsedMs);
                createdUsers.Add(newUser);
            }

            Console.WriteLine($"Users created: {users.Count} -Avg creation: {timespans.Average()} ms.");
            Console.WriteLine();
            Console.WriteLine("Do you want to delete the created users? (Y/N)");
            var confirmation = Console.ReadLine();

            if (!string.Equals(confirmation, "Y", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            foreach (var user in createdUsers)
            {
                var sw = Stopwatch.StartNew();
                client.UserDeleteAsync(user.ObjectId).Wait();
                Console.WriteLine($"User Deleted: ({sw.ElapsedMilliseconds} ms): {user.DisplayName} ({user.SignInNames.First().Value})");
            }
        }