/* * parameters: * domain, admin, adminPassword, user, hash, hashFunction, proxyAddress, proxyUser, proxyPassword */ static void Main(string[] args) { //Open the log file string applicationDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string logPath = Path.Combine(applicationDataDirectory, "GoogleHashUpdater.log"); log = new StreamWriter(logPath, true); try { if (args.Length < 6) { //wrong number of argument, exit Log("Program called with an incurrect number of arguments"); Environment.ExitCode = 10; return; } //Connect to google apps String domain = args[0]; String admin = args[1]; String adminPassword = args[2]; String user = args[3]; String hash = args[4]; String hashFunction = args[5]; AppsService service = new AppsService(domain, admin, adminPassword); //proxy settings if (args.Length >= 7) { GDataRequestFactory requestFactory = (GDataRequestFactory) service.CreateRequestFactory(); WebProxy myProxy = new WebProxy(args[6], true); // format: http://192.168.0.1:8080/ //setup credentials on the proxy here if (args.Length == 9) { myProxy.Credentials = new NetworkCredential(args[7], args[8]); } else { myProxy.Credentials = CredentialCache.DefaultCredentials; } requestFactory.Proxy = myProxy; service.SetRequestFactory(requestFactory); } try { //Search the user UserEntry entry = service.RetrieveUser(user); //change the pasword entry.Login.Password = hash; entry.Login.HashFunctionName = hashFunction; //save modification entry.Update(); } catch (LoggedException ex) { //On error log and close Log("Failed to update password: "******"Changed password for user \"{0}\"", user)); } finally { log.Close(); } }