MS Graph Guest用户无法读取Azure AD数据

时间:2018-06-04 07:45:03

标签: azure azure-active-directory microsoft-graph azureportal

我创建了一个在Application registration portal中注册的应用程序,并在那里获得了管理员同意。作为Azure AD中的用户,我可以使用我的网络应用来阅读,例如我在AD中被分配到的小组。

但是,当我邀请MS用户访问我们的AD(他在那里成为访客用户)时,用户可以登录该应用程序,但他无法读取这些组(使用与内部用户相同的方法)。我总是收到错误:" Authorization_RequestDenied没有足够的权限来完成操作。"

有没有办法让它发挥作用?我曾尝试浏览Azure门户以检查权限或其他任何内容,但到目前为止没有任何帮助。

1 个答案:

答案 0 :(得分:1)

实际上,对于AAD Graph API和Microsoft graph api,您不能使用MS帐户访客用户来读取组租户中的成员数据。

即使您可以设置public static void main(String[] args) { // TODO Auto-generated method stub } public void showdb() throws Exception { try { Connection con = getConnection(); String query = "SELECT *FROM studinfo;"; PreparedStatement showstuddb= con.prepareStatement(query); ResultSet rs = showstuddb.executeQuery(); System.out.println("Showing Database....................."); System.out.println("============================================================@ THE CONTENT OF THE DATABASE @============================================================"); while (rs.next()) { String idko = rs.getObject(1).toString(); String ngalan = rs.getObject(2).toString(); String numko=rs.getObject(3).toString(); String baitang=rs.getObject(4).toString(); String kurso=rs.getObject(5).toString(); String kasarian=rs.getObject(6).toString(); System.out.println("My ID number is: "+ idko + " Name is: " + ngalan + " Student Number is: " + numko + " Year/Level is: "+ baitang +" Course is: " + kurso + " Sex is: " + kasarian); } showstuddb.close(); System.out.println("Nothing follows....................."); con.close(); } catch (Exception e) { System.out.println("Error on showing contents of database!!!" + e.getMessage()); } } public void updstuddb () throws Exception { try { Connection con = getConnection(); String query = "UPDATE studinfo SET studName=?, studNum=?, studYrLvl=?, studKors=?, studGender=? WHERE studid=?"; PreparedStatement studup = con.prepareStatement(query); studup.setString(1, "Kakarot"); //This will be the replacement studup.setString(2, "2000000020"); studup.setString(3, "2"); studup.setString(4, "IT"); studup.setString(5, "dafq"); studup.setString(6, "1");// The unique element among the content of the database which is used to determine which is to update studup.executeUpdate(); System.out.println("THE LIST HAS BEEN UPDATED @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); studup.close(); con.close(); } catch (Exception e) { System.out.println("Error in updating the database!!!" + e.getMessage()); } } public void delstud() { try { Connection con = getConnection(); String query = "DELETE FROM studinfo WHERE studid=?"; PreparedStatement userdel = con.prepareStatement(query); userdel.setString(1, "12"); // To determine what to delete in the Database //userdel.setString(1, "2000000002"); //userdel.setString(1, "2000000003"); //userdel.setString(1, "2000000004"); //userdel.setString(1, "2000000005"); //userdel.setString(1, "2000000006"); //userdel.setString(1, "2000000007"); //userdel.setString(1, "2000000008"); //userdel.setString(1, "2000000009"); //userdel.setString(1, "2000000010"); userdel.execute(); userdel.close(); System.out.println("Data is now deleted!!!"); con.close(); } catch (Exception e) { System.out.println("Error!!!. Data is not deleted " + e.getMessage()); } } public void addstud(String studid, String studName, String studNum, String studYrLvl, String studKors, String studGender) throws Exception { //String var1 = "Yves Francisco"; //String num1 = "2000000001"; //String num2 = "5"; //String var2 = "CpE"; //String var3 = "Male"; try { Connection con = getConnection(); PreparedStatement posted= con.prepareStatement("INSERT INTO studinfo (studid, studName, studNum, studYrLvl, studKors, studGender) VALUES (?,?,?,?,?,?)"); int y=1; posted.setString(y++, studid); posted.setString(y++, studName); posted.setString(y++, studNum); posted.setString(y++, studYrLvl); posted.setString(y++, studKors); posted.setString(y++, studGender); posted.executeUpdate(); // Manipulate or Update table posted.close(); //con.close(); } catch (Exception e) { System.out.println("Error on adding columns!!!" + e.getMessage()); } finally { System.out.println("Insert Successful!"); } //FOR DUPLICATE INPUTS!!!!!!!!!!!!!!!! try { Connection con = getConnection(); String query = "SELECT studName, studNum, studYrLvl, studKors, studGender FROM studinfo WHERE studName=?, studNum=?, studYrLvl=?, studKors=?, studGender=?"; PreparedStatement checkdup = con.prepareStatement(query); ResultSet rs=checkdup.executeQuery(); while (rs.next()) { boolean dup1=rs.getObject(2).equals(studName); boolean dup2=rs.getObject(3).equals(studNum); boolean dup3=rs.getObject(4).equals(studYrLvl); boolean dup4=rs.getObject(5).equals(studKors); boolean dup5=rs.getObject(6).equals(studGender); System.out.println("The name you entered is: " + dup1 + " The student number you entered is: " + dup2 + " The Yr/Lvl you entered: " + dup3 + " The Course you entered: " + dup4 + " The Sex you entered is: " + dup5); } con.close(); } catch (Exception e) { System.out.println("You entered a duplicate value!!. Try Again! "); System.out.println("Take note that the entered Duplicate value is entered in the Database"); System.out.println("Remove the duplicate value using delstud() method!!!"); } } public void makeTable() throws Exception { try { Connection con= getConnection(); PreparedStatement create = con.prepareStatement("CREATE TABLE IF NOT EXISTS studinfo (studid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, studName varchar(255), studNum varchar(30), studYrLvl varchar(2), studKors varchar(30), studGender varchar(10));"); create.executeUpdate(); System.out.println("TABLE IS CREATED!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); create.close(); con.close(); } catch (Exception e) { System.out.println("Error on creating table!!. Table not created!"+e.getMessage()); } finally { System.out.println("Table created!"); }; } public Connection getConnection () throws Exception { try { String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/mydb"; String username= "root"; String password = "root"; Class.forName(driver); Connection conn= DriverManager.getConnection(url, username, password); System.out.println("You are now Connected!!"); return conn; // Return if it is successfully connected! } catch (Exception e) { System.out.println("Connection not Established!"+e.getMessage()); } return null; // Return if unsuccessful } ,但仍然无法获取该租户中某个群组的数据。这是因为该MS帐户不是该帐户的成员。因此,它无法指定要查询的租户。

我建议你可以在你的租户中使用/创建一个成员来实现这一点。