I have done coding in .Net to create google account using Google Apps Provisioning API. I am successful in creating Google Account but I am not being able to add user to particular Organization Unit and Group. I have achieved the goal of account creation like this:
//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";
}
After user is added, it gets created under main domain "Users" in Google. But I have to put that user into the Organization unit where they belong to, here in my case, I need to put the user into "Staff" Organization Unit. I am not sure what applicationName means, I am just using the project solution name or am I not using correct name here? What does applicatinName mean, and what should I use? I am using CustomerID as "GoogleCustomerId" in following code that I got from Google for our domain. I have done coding like this which doesn't work for adding user to Organization Unit:
//Adding User to Organization Unit
OrganizationService service = new OrganizationService("mydomain", "applicationName");
service.setUserCredentials("AdminUsername", "AdminPassword");
service.UpdateOrganizationUser("GoogleCustomerId", Email.Text, "Staff", "Users");
I get this exception with the above code to add user to Organization Unit:
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>
Here is my code to add user to Group but it is also not working, I need to add user to staff@mydomain.com group:
//Adding User to Group
service.Groups.AddMemberToGroup("staff@mydomain.com", username);
Any idea on this one please?
Thanks