Shared Mailbox in Microsoft graph in C# - c#

I'm trying to look for a way to identify shared mailbox and/or convert a regular mailbox to shared in C#.
From what I tried to look for I found nothing using GraphServiceClient.
I'm referring to getting a user with:
var users = await graphServiceClient.Users.Request().GetAsync();
or
var users = await graphServiceClient.Users.Request().Select("MailboxSettings").GetAsync();
and identifying if the user has a regular mailbox or shared.
Note: Not talking about shared folders
is there a way using Microsoft.Graph or any other way to identify and/or convert mailbox in asp?

As this feature is still available only in the Beta endpoint and not in V1.0, You can raise a feature for same and upvote it so that it can be moved to the V1.0 endpoint.
Feature Request:https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform.
Hope this helps.

Related

Microsoft graph API: Query to get list of subscriptions already created on mailbox for a specific user using userID

Is there any way to get list of subscriptions specific to a users mailbox like we have one for user's one-drive similar to the code below.
The is one end point available to fetch out all the subscriptions as https://graph.microsoft.com/v1.0/subscriptions
but I want to get only mailbox specific subscriptions.
IDriveItemSubscriptionsCollectionPage subscriptions = await graphClient.Users[{UserId}]
.Drive
.Root
.Subscriptions
.Request()
.GetAsync();
'''
Thank you for reaching out. To my knowledge, there isn't currently a way to do this with MS Graph, since listing the subscriptions doesn't support the OData query params. As a workaround, I would suggest fetching the list then filtering by the resource param client side once the response is sent by graph:
/users/{UserId}/messages
Would you consider filing a feature request on the M365 developer platform so this can be looked into?

Using Microsoft.Graph to get current application permissions

My C# program uses the Microsoft.Graph Nuget. And it needs be able to ensure that it has the correct Microsoft Graph application permissions.
I know how to add permissions in AD, but I want my program to be able test it has the permissions it needs.
Example of what I want to achieve :
var graphClient = new GraphServiceClient(authenticationProvider);
if(!graphClient.GetPermissions().Contains("AdministrativeUnit.Read.All"))
{
throw new Exception("Missing Permission AdministrativeUnit.Read.All")
}
Thanks in advance !
It's a long way.
Here I provide a general idea of Microsoft Graph beta version(through HTTP method):
Get the Object ID of the servicePrincipal based on the App ID: GET
https://graph.microsoft.com/beta/servicePrincipals?$filter=appId eq
'{App ID}'.
Get the appRole information (the application permission information)
based on the Object ID from step 1: GET
https://graph.microsoft.com/beta/servicePrincipals/{Object ID}/appRoleAssignedTo.
Get a match list of appRoleID and Microsoft Graph application permission name: GET
https://graph.microsoft.com/beta/servicePrincipals?$filter=appId eq
'00000003-0000-0000-c000-000000000000'. Please note that
"00000003-0000-0000-c000-000000000000" is a fixed value, which
represents the App ID of the Microsoft internal Graph App.
Compare the results of the 2nd and 3rd steps and you will know which
application permissions are in your Azure AD app.
By the way, Get appRoleAssignment is only available in beta version currently, but beta version api is not recommended to use.
APIs under the /beta version in Microsoft Graph are subject to change.
Use of these APIs in production applications is not supported.

Get Sharepoint Online Site using C# Graph SDK

I'm trying to use the Graph SDK to get a specific Sharepoint site by URL so I can read and write the list, create document libraries, and add documents to existing libraries.
This works to get the root:
var site = await graphClient.Sites[SPUrl].Request().GetAsync();
This doesn't work to get the site I want:
var site = await graphClient.Sites[SPUrl+"/segment1/segment2/site"].Request().GetAsync();
And this doesn't work to get the site by URL -- it tells me "the provided path does not exist or does not represent a site":
var siteByPath = await graphClient.Sites[SPUrl].SiteWithPath("/segment1/segement2/site").Request().GetAsync();
But using the Graph Explorer, this works:
https://graph.microsoft.com/v1.0/sites/my.site.com:/sites/segment1/segment2/site?$select=id
Using the Graph Explorer I determined that each segment of the URL is considered its own site, but didn't have any luck doing this -- the error is "provided identifier is malformed - id is not valid":
var site = await graphClient.Sites[SPUrl].Sites["segment1"].Request().GetAsync();
What am I missing?
With the Sharepoint CSOM you could just ask for a site by its URL. My application is in Azure now and being authenticated by through OAuth tokens, not by a username and password handled within the application, so I'm not sure I can pass that authentication through CSOM. As far as I can tell I need to use Graph now.
It would appear that the problem was that if you're going to query the sites under a site root, you need to add the ":" to your original root site string. So
"await graphClient.Sites[SPUrl].Sites["/segment1/segment2/site"].Request().GetAsync();" needs to be
"await graphClient.Sites[SPUrl+":"].Sites["/segment1/segment2/site"].Request().GetAsync();" which would make it match the syntax used in the Graph Explorer.
I had assumed that asking for a Site using the SDK would handle that, but I was wrong.

Bot Framework (.Net) - Retrieving Username of a specific user using the bot at a specific time in Microsoft Teams

I am trying to use my Bot in Microsoft Teams and I have an issue when obtaining the username of each specific user that is using the Bot. A static variable cannot be used since there is only one server and multiple users. I am using this as a reference. Is there any way that I can make use of so that I can get each user's Username?
Please note that when a user interacts with your bot, you will receive the name in the From section of the payload. We will also be adding user name in the Roster retrieval functionality so you can retrieve all team member names along with their UIDs.
In general, if you want to store names for future messages (e.g. push messages vs response), you'd need to use something like Bot Framework's user data store or for more robust support, something like Azure's Table storage.
I just used the AuthResult class to get the user details. The following is the code that I write whenever I want to display the Username.
AuthResult authResult; context.UserData.TryGetValue(ContextConstants.AuthResultKey, out authResult);
And obtain the Username using authResult.
i.e. authResult.UserName

Problems with integrating google calender

i am facing so much of confusions and problems while migrating from google api v2 over to v3.
I am dealing with the job scheduling of each employees in a company with the help of integrated google calender. i lost the full control while the provider change the version. let me know the following thing?
can i access the calender of an employee if his/her gmail id and its password is known?
is it needed to provide individual CLIENT ID and CLIENT secret?
what is the use of public Public API access(server key)
how to form the request url that must send to the server.
how to use the JSON file downloaded from the developer console
previously i was using the query as
Try
Dim myService As New CalendarService("test")
myService.setUserCredentials(user_name, user_password)
Dim query As New CalendarQuery()
query.Uri = New Uri("https://www.google.com/calendar/feeds/default/owncalendars/full")
Dim resultFeed As CalendarFeed = DirectCast(myService.Query(query), CalendarFeed)
Catch ex As Exception
lblerror.Text = ex.ToString
connect = 0
End Try
Can I access the calendar of an employee if his/her gmail id and its password is known?
no you must use Oauth2 Google Calendar Authentication
Is it needed to provide individual CLIENT ID and CLIENT secret?
No client_id and Client secret identify your project to Google you only need one.
what is the use of public Public API access(server key)
This is for public apis like Google Books API that do not require authentication.
how to form the request url that must send to the server.
I recommend you look into using the Google-api-dotnet-client lib it will handle all that for
you. Nuget
how to use the JSON file downloaded from the developer console
you don't really need to use it if you use the client lib it just contains the same data as you already asked about open it and see
previously i was using the query as
That is VB code I think and not C# that's not how you will be doing it now. I recommend you start by reading Google Calendar API Authentication with C#

Categories