【发布时间】:2014-10-14 16:47:49
【问题描述】:
我已在 .Net 中完成编码,以使用 Google Apps Provisioning API 创建 google 帐户。我成功创建了 Google 帐户,但无法将用户添加到特定的组织单位和组。我已经实现了这样的帐户创建目标:
//Creating Google Account
AppsService appService = new AppsService("Mydomain", "AdminUsername", "AdminPassword");
try
{
var account = appService.CreateUser(googleEmail, FirstName.Text, LastName.Text, password);
}
catch (Exception ex)
{
ResultsLabel.Text += "<br />Can't create this Google Account";
}
添加用户后,它会在 Google 的主域“用户”下创建。但是我必须将该用户放入他们所属的组织单位,在我的情况下,我需要将用户放入“员工”组织单位。我不确定 applicationName 是什么意思,我只是使用项目解决方案名称还是我在这里没有使用正确的名称? applicatinName 是什么意思,我应该使用什么?在我从 Google 为我们的域获得的以下代码中,我使用 CustomerID 作为“GoogleCustomerId”。我已经完成了这样的编码,这不适用于将用户添加到组织单位:
//Adding User to Organization Unit
OrganizationService service = new OrganizationService("mydomain", "applicationName");
service.setUserCredentials("AdminUsername", "AdminPassword");
service.UpdateOrganizationUser("GoogleCustomerId", Email.Text, "Staff", "Users");
我使用上述代码将用户添加到组织单位时遇到此异常:
Google.GData.Client.GDataRequestException was unhandled by user code
HResult=-2146233088
Message=Execution of request failed: https://apps-apis.google.com/a/feeds/orguser/2.0/C090ll5hh/Test@domain.com
Source=Google.GData.Client
ResponseString=<?xml version="1.0" encoding="UTF-8"?>
<AppsForYourDomainErrors>
<error errorCode="1801" invalidInput="" reason="InvalidValue" />
</AppsForYourDomainErrors>
这是我将用户添加到组的代码,但它也不起作用,我需要将用户添加到 staff@mydomain.com 组:
//Adding User to Group
service.Groups.AddMemberToGroup("staff@mydomain.com", username);
请问有这方面的想法吗?
谢谢
【问题讨论】:
标签: c# .net google-api google-provisioning-api