如何通过API检测两个Office365用户在同一个组织中工作?

时间:2017-08-31 16:30:10

标签: microsoft-graph

在我的应用程序中,用户使用他们的Office365凭据登录,然后 我想在同一个网站中导入用户的数据(MASTER<- read.csv("c:\\users\\Desktop\\test merge\\MASTER.csv", header=T, sep=",") > MASTER = c("CALIFORNIA","ARIZONA","ARKANSAS","colorado","CONNECTICUT","DISTRICT OF COLUMBIA","FLORIDA","Georgia","hawaii","Illinois","Indiana","Iowa","kansas","Kentucky","LOUISIANA","Maine","Marryland","Massachusetts","Michigan","Minnesota","Missouri","MONTANA","NEBRASKA","Nevada","New Hampshire","New Jersey","NEW MEXICO","New York","North Carolina","OHIO","OKLAHOMA","Oregon","palmer","PANAMA","Pennsylvania","SOUTH CAROLINA","SOUTH DAKOTA","Tejas","Tennessee","Texas","TX.","UTAH","Virgin Islands","VIRGINIA","Washington","West Virginia","WISCONSIN","Wyoming") > MASTER$state <- state.abb[match(MASTER$state,state.name)] Error in `$<-.data.frame`(`*tmp*`, state, value = character(0)) : replacement has 0 rows, data has 635768 idmail) 组织到我的数据库。

当来自同一组织的其他人登录到我的应用程序时,另一个人 person应该看到与第一个用户相同的用户列表。

我在Graph Explorer中尝试了几个查询,但没有 他们有一个回应,这将允许确定两个人属于 到同一个组织。

“我的个人资料”(displayName)回复包含很多内容 数据,但没有租户ID(或类似的东西):

/v1.0/me/

同样适用于“组织中的所有用户”({ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", "id": "16f5a7b6-5a15-4568-aa5a-31bb117e9967", "businessPhones": [], "displayName": "Anne Weiler", "givenName": "Anne", "jobTitle": "Manufacturing Lead", "mail": "annew@CIE493742.onmicrosoft.com", "mobilePhone": "+1 3528700812", "officeLocation": null, "preferredLanguage": "en-US", "surname": "Weiler", "userPrincipalName": "annew@CIE493742.onmicrosoft.com" } )回复。

如何从Microsoft Graph中提取允许我这样做的信息 检测到两个不同的用户在同一个组织中工作?

1 个答案:

答案 0 :(得分:1)

您可以使用/organiozation端点返回的id

https://graph.microsoft.com/v1.0/organization?$select=id,displayName

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization(id,displayName)",
    "value": [
        {
            "id": "c07ab59f-ce09-49f8-b4c4-9c6dd4f0d8bb",
            "displayName": "Microsoft API Sandbox"
        }
    ]
}