如何使用 C# 在 exchange server 中获取日历的用户权限
How to get user permissions on calendar in exchange server using c#
我正在我的网络中使用交换日历 application.Before 从我的网络应用程序向日历插入事件以交换服务器 我想在我的 c# 上获得该特定日历的用户权限 side.I 通过执行以下 powershell 命令获得了许可。但坚持使用 c# 获得相同的权限。
Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User "test@test.com"
我无法在不调用 powershell 的情况下找到任何方法,但可以这样做:
var runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
object psSessionConnection;
// Create a powershell session for remote exchange server
using (var powershell = PowerShell.Create())
{
var command = new PSCommand();
command.AddCommand("Get-MailboxFolderPermission");
command.AddParameter("Identity", "john@contoso.com:\Calendar");
command.AddParameter("User", "test@test.com"));
powershell.Commands = command;
powershell.Runspace = runspace;
var result = powershell.Invoke();
psSessionConnection = result[0];
}
您所做的实际上是 运行 来自代码本身的 PS 命令。
我还找到了 EWS api,其中可能包含您要查找的内容。
Getting the current permissions for a folder by using the Bind method.
// Create a property set to use for folder binding.
PropertySet propSet = new PropertySet(BasePropertySet.FirstClassProperties, FolderSchema.Permissions);
// Bind to the folder and get the current permissions.
// This call results in a GetFolder call to EWS.
Folder sentItemsFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "test@test.com"), propSet);
我正在我的网络中使用交换日历 application.Before 从我的网络应用程序向日历插入事件以交换服务器 我想在我的 c# 上获得该特定日历的用户权限 side.I 通过执行以下 powershell 命令获得了许可。但坚持使用 c# 获得相同的权限。
Get-MailboxFolderPermission -Identity john@contoso.com:\Calendar -User "test@test.com"
我无法在不调用 powershell 的情况下找到任何方法,但可以这样做:
var runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
object psSessionConnection;
// Create a powershell session for remote exchange server
using (var powershell = PowerShell.Create())
{
var command = new PSCommand();
command.AddCommand("Get-MailboxFolderPermission");
command.AddParameter("Identity", "john@contoso.com:\Calendar");
command.AddParameter("User", "test@test.com"));
powershell.Commands = command;
powershell.Runspace = runspace;
var result = powershell.Invoke();
psSessionConnection = result[0];
}
您所做的实际上是 运行 来自代码本身的 PS 命令。
我还找到了 EWS api,其中可能包含您要查找的内容。
Getting the current permissions for a folder by using the Bind method.
// Create a property set to use for folder binding.
PropertySet propSet = new PropertySet(BasePropertySet.FirstClassProperties, FolderSchema.Permissions);
// Bind to the folder and get the current permissions.
// This call results in a GetFolder call to EWS.
Folder sentItemsFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, "test@test.com"), propSet);