Well, after a lot of help from posts on this site and others I've finally got my .net application connected and authenticating to my google apps instance! Hooray! I can search and get user details to my hearts delight utilizing a service account that I've delegated access to.
That said, I can't seem to be able to update a user's password. I get no errors, no response, nothing - it just doesn't work.
Here's what I got so far, like i said, i get user details great, just can't change that password!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Admin.Directory.directory_v1;
using Google.Apis.Admin.Directory.directory_v1.Data;
using Google.Apis.Admin.Directory;
String serviceAccountEmail = "mybiglongserviceaccountemail@developer.gserviceaccount.com";
var certificate = new X509Certificate2(@"c:\path\to\my\p12key.p12", "mysecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User="myadminuser@mydomain.com",
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser }
}.FromCertificate(certificate));
var dirservice = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "MyProjectName",
});
User user = dirservice.Users.Get("username@mydomain.com").Execute();
Console.WriteLine(" email: " + user.PrimaryEmail);
Console.WriteLine(" last login: " + user.LastLoginTime);
user.Password = "newpassword";
dirservice.Users.Update(user, "username@mydomain.com");
The last two lines are the ones I expect would change the users password - but it doesn't.
Any help here would be much appreciated! Thanks so much!