【发布时间】:2021-11-24 00:51:45
【问题描述】:
我有一个内置在 .NET 中的脚本,可以批量创建用户并创建别名。
用户是在 Google 管理控制台中创建的,但它似乎没有完成电子邮件别名信息。检查管理控制台后,备用电子邮件字段为空白
这是错误信息:
Google.Apis.Requests.RequestError 用户创建未完成。 [412] 错误 [消息[用户创建未完成。] Location[If-Match - header] Reason[conditionNotMet] Domain[global]]]
这是我的脚本:
// create new Gmail user
Google.Apis.Admin.Directory.directory_v1.Data.User newuserbody = new Google.Apis.Admin.Directory.directory_v1.Data.User();
UserName newusername = new UserName();
newuserbody.PrimaryEmail = userEmail;
newusername.GivenName = sFirst;
newusername.FamilyName = sLast;
newuserbody.Name = newusername;
newuserbody.Password = sPass;
Google.Apis.Admin.Directory.directory_v1.Data.User
user = service.Users.Insert(newuserbody).Execute();
user = null;
}
catch (Exception e) {
LogMessage("CreateGoogleEmailApps", "Error", String.Format("Google user [{0}] could not be created at this time with error: {1}", sUN, e.Message));
}
try {
// nickname attempt
Alias newalias = new Alias();
newalias.AliasValue = string.Format("username-{0}@{1}", sPass, ASAS_Create.Properties.Settings.Default.G_DOMAIN);
Alias useralias = service.Users.Aliases.Insert(newalias, userEmail).Execute();
newalias = null;
} catch (Exception e) {
//LogMessage("CreateGoogleEmailApps", "Error", String.Format("Google user [{0}]'s alias could not be created at this time.", sUN));
LogMessage("CreateGoogleAliasApps", "Error", string.Format("Google Alias Error for user [{0}] with error message[{1}].", sUN, e.Message));
}
【问题讨论】:
标签: c# .net google-directory-api