Adding the photo in WSP Active Directory users. part 1

This commit is contained in:
dev_amdtel 2015-05-21 17:17:18 +03:00
parent 2d1d464c43
commit 642890f4dc
5 changed files with 136 additions and 1 deletions

View file

@ -49,6 +49,7 @@ using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.Utils;
using WebsitePanel.Server.Utils;
using WebsitePanel.Providers.Common;
using WebsitePanel.Providers.ResultObjects;
using Microsoft.Exchange.Data.Directory.Recipient;
using Microsoft.Win32;
@ -7969,6 +7970,67 @@ namespace WebsitePanel.Providers.HostedSolution
#endregion
#region Picture
public virtual ResultObject SetPicture(string accountName, byte[] picture)
{
ExchangeLog.LogStart("SetPicture");
ResultObject res = new ResultObject() { IsSuccess = true };
Runspace runSpace = null;
try
{
runSpace = OpenRunspace();
Command cmd;
cmd = new Command("Import-RecipientDataProperty");
cmd.Parameters.Add("Identity", accountName);
cmd.Parameters.Add("Picture", true);
cmd.Parameters.Add("FileData", picture);
ExecuteShellCommand(runSpace, cmd, res);
}
finally
{
CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("SetPicture");
return res;
}
public virtual BytesResult GetPicture(string accountName)
{
ExchangeLog.LogStart("GetPicture");
BytesResult res = new BytesResult() { IsSuccess = true };
Runspace runSpace = null;
try
{
runSpace = OpenRunspace();
Command cmd;
cmd = new Command("Export-RecipientDataProperty");
cmd.Parameters.Add("Identity", accountName);
cmd.Parameters.Add("Picture", true);
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd, res);
if (result.Count > 0)
{
//res.Value = ;
}
}
finally
{
CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("GetPicture");
return res;
}
#endregion
}
}