Created
June 18, 2012 02:39
-
-
Save soundTricker/2946531 to your computer and use it in GitHub Desktop.
Google Apps Script GroupsManager and NicknameManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function グループ() { | |
// {ユーザ名}@{ドメイン名}のユーザ名の部分を指定 | |
var user = UserManager.getUser("k-ohashi"); | |
//全グループの取得 | |
var groups = GroupsManager.getAllGroups(); | |
for(var i = 0; i < groups.length; i++) { | |
Logger.log(groups[i].getName()); | |
} | |
var group = null; | |
try { | |
//特定グループの取得 | |
group = GroupsManager.getGroup("create-test100"); | |
} catch(e) { | |
if(e.message.indexOf("EntityDoesNotExist")>0) { //存在しないとき | |
//createGroups("メールアドレスのアカウント部" , "名称"); | |
group = GroupsManager.createGroup("create-test100", "テスト"); | |
} else { | |
throw e; | |
} | |
} | |
//var group = GroupsManager.getGroup(""); | |
//ユーザの追加 | |
group.addMember(user.getUserLoginId()); | |
//ユーザの削除 | |
group.removeMember(user.getUserLoginId()); | |
//オーナーの追加 | |
group.addOwner(user.getUserLoginId()); | |
//オーナーの削除 | |
group.removeOwner(user.getUserLoginId()); | |
//すべてのユーザの取得 | |
group.getAllMembers(); | |
//すべてのオーナーの取得 | |
group.getAllOwners(); | |
//詳細の設定 | |
group.setDescription("詳細"); | |
//名称の変更 | |
group.setName("名称"); | |
//アクセス権のレベルせて値 GroupsManager.PermissionLevel.ANYONE / DOMAIN / MEMBER / OWNERがある | |
group.setPermissionLevel(GroupsManager.PermissionLevel.DOMAIN); | |
// グループの削除 | |
group.deleteGroup(); | |
} | |
function ニックネーム() { | |
//{ユーザ名}@{ドメイン名}のユーザ名の部分を指定 | |
var user = UserManager.getUser("k-ohashi"); | |
//すべてのnicknameの取得 | |
var nicknames = NicknameManager.getAllNicknames(); | |
for(var i = 0;i < nicknames.length;i++) { | |
Logger.log(nicknames[i].getNickname()); | |
} | |
var nickname = null; | |
try { | |
//ニックネームの取得 | |
nickname = NicknameManager.getNickname("keisuke.oohashi"); | |
}catch(e) { | |
if(e.message.indexOf("EntityDoesNotExist") > 0) { | |
//新しいnicknameの作成 | |
nickname = NicknameManager.createNickname("k-ohashi", "keisuke.oohashi"); | |
} else { | |
throw e; | |
} | |
} | |
//ニックネームの削除 | |
nickname.deleteNickname(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment