In EWS Managed API is it easy to create an appointment for a specific user:
ExchangeService service = new ExchangeService();
service.Credentials = new NetworkCredentials ( "administrator", "password", "domain" );
service.AutodiscoverUrl(emailAddress);
Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save();
This will create a appointment for the administrator. But say I wanted to actually create an appointment for another user (not add that user as an attendee to me appointment). It this possible via the EWS Managed API?
Folder inboxFolder = Folder.Bind(service, new FolderId(WellKnownFolderName.Inbox, "user1#example.com"));
Will work too.
Then pass inboxFolder.id to the Appointment.Save call. The updates and deletes don't need this.
The best answer is to use impersonate, but this requires it to be enabled by the server admins. If you don't wield such power, this method will let you do what you need.
Note: the user running your application must have permissions on the target account or this will fail (as it should).
Found here: http://msdn.microsoft.com/en-us/library/gg274408(v=EXCHG.80).aspx
I know this has been answered but in answer to #Aamir's comment you can do this using delegates I've just done it for a project I'm working on.
As #matt suggested in his answer you can amend the save method of the appointment to point to the other users folder which in this case would be Calendar.
Code would look as below
Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours(1);
appointment.Save(new FolderId(WellKnownFolderName.Calendar, new Mailbox(_EmailAddress)));
Hope that helps
I figured it out from this article:
http://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx
You should use the service.ImpersonatedUserId attribute.
Related
i use laravel V6
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'token..',
'token..'
)
);
//dd($transaction);
$callbackUrl = url('/paypal/status');
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');
$amount = new \PayPal\Api\Amount();
$amount->setTotal('1.00');
$amount->setCurrency('USD');
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl($callbackUrl)
->setCancelUrl($callbackUrl);
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setTransactions(array($transaction))
->setRedirectUrls($redirectUrls);
try {
$payment->create($apiContext);
//dd($payment);
//dd($payment->getApprovalLink());
return redirect()->away($payment->getApprovalLink());
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
var_dump(json_decode($ex->getData()));
exit(1);
}
that's the controller, I followed the documentation enter link description here
but I get a 400 error enter link description here
The link it generates is as follows https://www.sandbox.paypal.com/webapps/hermes?flow=1-P&ulReturn=true&token=EC-88M93704JL735000S&country.x=US&locale.x=es_XC#/checkout/genericError?code=UEFZTUVOVF9ERU5JRUQ%3D
I can not understand why the error .. the client_id secret, are fine .. anyway it is directly in the controller and check that the sandbox account has a balance
For that ClientId/Secret it looks like the receiving account in the PayPal sandbox is from a country that cannot receive any payments, such as Bolivia. Create a new sandbox business account at https://www.paypal.com/signin?intent=developer&returnUri=https%3A%2F%2Fdeveloper.paypal.com%2Fdeveloper%2Faccounts%2F for a different country that is able to receive PayPal payments, and then create a REST app for this new sandbox business account in the 'My Applications' side tab.
It looks like you are using an obsolete PHP integration, with the old v1 payments SDK
You should instead use the v2 Checkout-PHP-SDK, with two routes, one for 'Set Up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/
Instead of redirecting to the approval URL, use this front-end UI: https://developer.paypal.com/demo/checkout/#/pattern/server -- this gives an "in context" checkout experience that keeps your site loaded in the background, which provides a much superior modern web experience
I am making an application using laravel and twilio that gets feedback about student performance. The logic as follows.
A user, in my case the Student(called resident) logs in and uses a
web page form to send an eval request to a teacher (called
attending). This step starts a session and saves teacher info and
student info.
A random question is picked from a database and saved to the session.
The phone number of the teacher is pulled from a database and the random question is pulled from session and sent to the teacher on SMS using twilio.
The teacher responds with yes, no, or DNS (did not see) via Twilio SMS.
The teacher's response along with the student name, the teacher name and the question asked are saved to a database.
My application works up until step 5. The problem is that a new session is being started when the teacher responds via SMS. So everything after the response is saved to a new session. I can't get access to the original session. I think I need a way to automatically grant the teacher access to the student(ie. user's account). This seems to be a problem with it being a 3rd party application. Can this be done or is there another way to accomplish this?
Below is the code I am using for the response. It is not able to access the session that contains the residentName, the firstQuestion, or the attending_name data. It puts null for those values and uploads null to the database. How do I get access to the initial session in this situation?
namespace App\Http\Controllers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Session;
use Twilio\Rest\Client;
use Twilio\Twiml;
use App\Question;
use App\Answer;
class AskFirstQuestionsController extends Controller
{
public function qOneResponse(Request $request) {
$responderNumber = $request->input('From');
session()->put('responderNumber', $responderNumber);
session()->save();
$responderAnswer = strtolower($request->input('Body'));
$residentName = session::get('residentName');
$firstQuestion = session::get('first_question');
$attending_name = session::get('attending_name');
if (strpos($responderAnswer, 'yes') !== false) {
$answer = new
Answer(['attending'=>$attending_name,'resident_name'=>$residentName,'question_body'
=>$firstQuestion, 'answer_yes'=>1]);
$answer->save();
$smsResponse = "Great! Please help us reinforce this action by providing specific feedback
to the resident about what they did. Thank You for teaching!";
} else if (strpos($responderAnswer, 'no') !== false) {
$answer = new
answer::create(['attending'=>$attending_name,'resident_name'=>$resident_name,'question_body'
=>$firstQuestion, 'answer_no'=>1]);
$answer->save();
$smsResponse = "Ugh, ok...we will work on this. If you feel comfortable, please help us by
providing specific feedback to the resident about what they need to work on. Thank You for
teaching!";
} else if (strpos($responderAnswer, 'dns') !== false) {
$answer = new
answer::create(['attending'=>$attending_name,'resident_name'=>$resident_name,'question_body'
=>$firstQuestion, 'answer_dns'=>1]);
$answer->save();
$smsResponse = "How about trying a different question?";
} else {
$smsResponse = 'Please answer yes, no or dns.';
}
return response($this->respond($smsResponse))->header('Content-Type', 'application/xml');
}
public function respond($smsResponse) {
//get responderNumber and use it below
$responderNumber = session::get('responderNumber');
$response = new Twiml();
$response->message($smsResponse, ['to' => $responderNumber]);
return $response;
}
Do I need to do some type of multiauth approach and somehow grant the teacher automatic access to the student's account (user account)? Or do I have to re-write the logic so that the response-request lifecycle closes and then try to write to the database (maybe it will then use the original session data?)? Or is there a simpler way? Please help. I have been stuck for more than a week.
Twilio developer evangelist here.
I'm not a Laravel developer, but session objects in web application frameworks like this are normally tied to a cookie that either stores the contents of the session or an ID for the session which points to the contents in a database in order to add state to a user's session within a browser.
When Twilio receives an incoming SMS message the webhook that is sent to your server is not connected to the browser session that the user is part of, so you cannot access the same data.
Instead of using the session, you should store this as part of your actual database so that you can look up the details from the database when you receive the SMS.
I need to check a property of my PFUser's in beforeSave triggers for each of my classes to determine if that user should be allowed to edit the piece of data they are attempting to edit.
For example, if a non-admin PFUser is attempting to edit or add to a class they shouldn't be allowed to, I want to prevent that in the beforeSave trigger. I access the keys being edited using dirtyKeys.
Parse-Server doesn't support .currentUser() like the old Parse server used to. How can I access the PFUser who is making the request? Is there a way to do it besides through session tokens?
Parse.Cloud.beforeSave("Class", function(request, response) {
//Get the keys that're being edited and iterate through them
var dirtyKeys = request.object.dirtyKeys();
for (var i = 0; i < dirtyKeys.length; ++i) {
var dirtyKey = dirtyKeys[i];
//Allow or don't allow editing of each key
if (userObject.get("<KEY>")) {
console.log('Class before save trigger IS key');
//ADD CLASS SPECIFIC FUNCTIONALITY HERE
} else {
console.log('Class before save trigger NOT key');
//ADD CLASS SPECIFIC FUNCTIONALITY HERE
}
}
});
Turns out the answer is much more obvious than I anticipated and was in the docs but I overlooked it despite my searching.
Since Parse.User.current() isn't working in Parse Server, the replacement is simply request.user. I was able to easily access all the data I needed from this and am good to go.
var user = request.user; // request.user replaces Parse.User.current()
I'm working on an application that let users manage their emails from a website.
The user can reply to an email as well as forward a an email etc....
My problem is that I want to give the users the ability to remove attachments from
a forward instance of an existing email before sending it.
ResponseMessage response;
response = OriginalEmail.CreateForward(); // create response
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
The ForwardEmail doesn't contain any attachment in the attachments collection.
However when using
ResponseMessage response;
response = this.Email.CreateForward(); // create response
this.Response = response.Save(WellKnownFolderName.Drafts);
this.Response.ToRecipients.Add("me", "me#gmail.com");
this.Response.Send();
I'm getting the attachments in the destination email.
How can I edit the attachments before forwarding?
Thanks in advance
After you call the Save method
ForwardEmail = response.Save(WellKnownFolderName.Drafts);
You should then do Load using a propertySet the specifies you want the attachments returned eg
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
ForwardEmail.Load(psPropset);
That should then populate the Attachment Collection.
Cheers
Glen
I would like to execute the below line when the user logs in so that I have access to the MembershipUser object. However I am having a hard time figuring out when to set it.
Session["User"] = Membership.GetUser();
So far I've tried...
Application_AcquireRequestState
Application_BeginRequest
FormsAuthentication_OnAuthenticate
For each the session state isn't necessarily available.
Manually calling it in the log-in page is easy, but I need to have it work when automatically logging in using cookies as well.
If all you want do is store arbitrary data along with the username, there is an open source project called FormsAuthenticationExtensions that allows you to do exactly this in a very simple manner:
In your Login action you would store your data like this:
var ticketData = new NameValueCollection
{
{ "name", user.FullName },
{ "emailAddress", user.EmailAddress }
};
new FormsAuthentication().SetAuthCookie(user.UserId, true, ticketData);
And you read it back like this:
var ticketData = ((FormsIdentity) User.Identity).Ticket.GetStructuredUserData();
var name = ticketData["name"];
var emailAddress = ticketData["emailAddress"];
Data is stored in the same cookie holding the authentication ticket, so it will be available for as long as the user is logged in.
Project page: http://formsauthext.codeplex.com/
Nuget: http://nuget.org/List/Packages/FormsAuthenticationExtensions
Why? You can access Membership.GetUser from anywhere. It's a static method. What is the point of placing a value you can access from anywhere in a place you can access from anywhere?