Esempio n. 1
0
    def share(self, user_principal_name,
              shareOption=ExternalSharingSiteOption.View,
              sendEmail=True, emailSubject=None, emailBody=None):
        """
        Share a Web with user

        :param str user_principal_name: User identifier
        :param ExternalSharingSiteOption shareOption: The sharing type of permission to grant on the object.
        :param bool sendEmail: A flag to determine if an email notification SHOULD be sent (if email is configured).
        :param str emailSubject: The email subject.
        :param str emailBody: The email subject.
        :rtype: SharingResult
        """

        picker_result = ClientResult(self.context)
        sharing_result = ClientResult(self.context, SharingResult(self.context))

        def _picker_value_resolved(picker_value):
            picker_result.value = picker_value

        def _grp_resolved(role_value):
            def _web_loaded():
                sharing_result.value = Web.share_object(self.context, self.url, picker_result.value, role_value,
                                                        0,
                                                        False, sendEmail, False, emailSubject, emailBody)

            self.ensure_property("Url", _web_loaded)

        params = ClientPeoplePickerQueryParameters(user_principal_name)
        ClientPeoplePickerWebServiceInterface.client_people_picker_resolve_user(self.context, params,
                                                                                _picker_value_resolved)
        Web._resolve_group_value(self.context, shareOption, _grp_resolved)
        return sharing_result.value
Esempio n. 2
0
    def share(self,
              user_principal_name,
              share_option=ExternalSharingSiteOption.View,
              send_email=True,
              email_subject=None,
              email_body=None):
        """
        Share a ListItem (file or folder facet)

        :param str user_principal_name: User identifier
        :param ExternalSharingSiteOption share_option: The sharing type of permission to grant on the object.
        :param bool send_email: A flag to determine if an email notification SHOULD be sent (if email is configured).
        :param str email_subject: The email subject.
        :param str email_body: The email subject.
        :rtype: SharingResult
        """

        result = ClientResult(self.context, SharingResult(self.context))
        file_result = ClientResult(self.context)

        role_values = {
            ExternalSharingSiteOption.View: "role:1073741826",
            ExternalSharingSiteOption.Edit: "role:1073741827",
        }

        def _property_resolved():
            file_result.value = self.get_property("EncodedAbsUrl")

        def _picker_value_resolved(picker_value):
            from office365.sharepoint.webs.web import Web
            result.value = Web.share_object(self.context, file_result.value,
                                            picker_value,
                                            role_values[share_option], 0,
                                            False, send_email, False,
                                            email_subject, email_body)

        self.ensure_property("EncodedAbsUrl", _property_resolved)
        params = ClientPeoplePickerQueryParameters(user_principal_name)
        ClientPeoplePickerWebServiceInterface.client_people_picker_resolve_user(
            self.context, params, _picker_value_resolved)
        return result.value
Esempio n. 3
0
 def test1_get_search_results(self):
     params = ClientPeoplePickerQueryParameters(test_user_principal_name)
     result = ClientPeoplePickerWebServiceInterface.client_people_picker_resolve_user(
         self.client, params)
     self.client.execute_query()
     self.assertIsNotNone(result.value)