解决:Google管理员目录API:添加用户员工详细信息 [英] Solved: Google Admin Directory API: Add User Employee Details

本文介绍了解决:Google管理员目录API:添加用户员工详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有了使用Google管理员目录添加用户的工作功能:

I already have a working function for adding user using Google Admin Directory:

string password = Random_Password();

User newuserbody = new User();
UserName newusername = new UserName();
UserOrganization newuserorg = new UserOrganization();

newusername.GivenName = GivenName;
newusername.FamilyName = FamilyName;
newuserbody.Name = newusername;

newuserorg.Department = Department;
newuserorg.CostCenter = Country;
newuserorg.Title = JobTitle;

newuserbody.Organizations = newuserorg;

newuserbody.PrimaryEmail = GivenName + "." + FamilyName + email_suffix;
//SET PASSWORD
newuserbody.Password = password;

service.Users.Insert(newuserbody).Execute();

此代码有效,但部门,成本中心和标题等详细信息未保存记录。只有第一,姓,电子邮件和密码的作品。
希望你能帮助我。
谢谢。

This code works, but the details such as Department, Cost Center, and Title doesn't save on the record. Only First, Last name, email and password works. Hope you can help me on this. Thanks.

更新:我刚解决了它。

以下是代码:

        UserOrganization[] newuserorg = new UserOrganization[1];

        newuserorg[0] = new UserOrganization();
        newuserorg[0].Department = Department;
        newuserorg[0].CostCenter = Country;
        newuserorg[0].Title = JobTitle;

        newuserbody.Organizations = newuserorg;

        newuserbody.PrimaryEmail = GivenName + "." + FamilyName + email_suffix;
        //SET PASSWORD
        newuserbody.Password = password;

        service.Users.Insert(newuserbody).Execute();


推荐答案

您应该尝试

you should try

List<UserOrganization> l = new List<UserOrganization> { newuserorg };
newuserbody.Organizations = l;

这篇关于解决:Google管理员目录API:添加用户员工详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆