Showing posts with label APP in SharePoint. Show all posts
Showing posts with label APP in SharePoint. Show all posts

Thursday, January 7, 2021

Getting ALL users from SharePoint online tenant and set userprofile property via Powershell

Getting all user profiles within SharePoint tenant using SharePoint Online CSOM API

  • retrieve all the users in tenant (Get-MsolUser cmdlet)
  • iterate users and utilize SharePoint User Profiles CSOM API to retrieve user profile

function Get-SPOContext([string]$Url,[string]$UserName,[string]$Password)
{
   $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
   $context.Credentials = Get-SPOCredentials -UserName $UserName -Password $Password
   return $context
}


function Get-SPOCredentials([string]$UserName,[string]$Password)
{
   $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
   return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
}



function Print-UserProfileInfo([Microsoft.SharePoint.Client.UserProfiles.PeopleManager]$PeopleManager,[string]$AccountName){
   $ctx = $PeopleManager.Context
   $accountName = "i:0#.f|membership|" + $AccountName  #claim format  
   $userProfile = $PeopleManager.GetPropertiesFor($AccountName)
   $ctx.Load($userProfile)
   $ctx.ExecuteQuery()
   Write-Host $userProfile.PersonalUrl
}

Change permissions of a SharePoint list using JavaScript?

Break role inheritance for a List object and grant Full Control permissions for a current user



 var listTitle = 'Documents';

var spCtx = SP.ClientContext.get_current();

var list = spCtx.get_web().get_lists().getByTitle(listTitle);   


spCtx.load(list,'HasUniqueRoleAssignments'); 

spCtx.executeQueryAsync(

   function(){

      var hasUniqueAssgns = list.get_hasUniqueRoleAssignments();

      if(!hasUniqueAssgns) {

         list.breakRoleInheritance(false, true);

         spCtx.executeQueryAsync(

            function(){

                console.log('Success');

            }, 

            function(sender,args){

               console.log(args.get_message());    

            }

         );

      }

   }, 

   function(sender,args){

      console.log(args.get_message());    

   }

);

Thursday, November 3, 2016

SharePoint App giving credentials popup




  1. Click on Start -> Run and type regedit.
  2. Locate the key 3. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. Right click on this key and choose New > DWord Value
  4. Name this one "DisableLoopbackCheck"
  5. Double-click then on it and type the value “1”
  6. Reboot your server. (Mostly not required)

This helped me in resolving the issue. I am using windows server 2012 and on creating new dword it prompts 32 or 64 bit. I created 64 bit but it does not resolve the issue. I deleted that and created 32 bit dword DisableLoopbackCheck and setting its value 1 resolved my problem.

Thursday, October 20, 2016

The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.

db_owner permissions to the account 

For this Open the DataBase,
 expand Security -> Logins -> right click on the account and go to properties. 
 properties window, click on User Mappings from the left side. 
Then you can select the database and select the permission as db_owner as shown in the fig below and click on OK.

Monday, June 20, 2016

Content editor webpart overrides Sharepoint CSS

 CSS, Selectors and its rules for CSS Specificity and you will be able to master any CSS problem.

In your scenario you can wrap your content in a DIV unique  selectors ID

<div id='myCEWP'>
  <H1>Hello World!</H1>
</div>
And then apply your CSS only to that one H1 in the DIV :

<style>
   #myCEWP > H1 {
     color:green;
   }
</style>

Thursday, May 19, 2016

Set list item level permission in jsom (javascript object model)

ar siteUrl = '/sites/peakfinder';

function breakSecurityInheritanceChangeUser() {    
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Employee');    
    var itemId = 5;
    this.oListItem = oList.get_items().getById(itemId);    
//Break Role Inheritance
    oListItem.breakRoleInheritance(true);    
//Get user from the site
    this.oUser = clientContext.get_web().get_siteUsers().getByLoginName('peakfinder\\testuser1');    
    oListItem.get_roleAssignments().getByPrincipal(oUser).deleteObject();    
    var collRoleDefinitionBinding = SP.RoleDefinitionBindingCollection.newObject(clientContext);

    collRoleDefinitionBinding.add(clientContext.get_web().get_roleDefinitions().getByType(SP.RoleType.administrator));
//assign the user
    oListItem.get_roleAssignments().add(oUser, collRoleDefinitionBinding);    
    clientContext.load(oUser);
    clientContext.load(oListItem);        

    clientContext.executeQueryAsync(Function.createDelegate(this, this.Success), Function.createDelegate(this, this.Failure));
}

function Success(sender, args) {    
    alert('Role inheritance broken for item ' + 
        this.oListItem.get_item('Title') + 
        ' and new role assignment for ' + 
        this.oUser.get_loginName());
}

function Failure(sender, args) {    
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Tuesday, April 26, 2016

Item Adding / Item Added Event Receiver for Document Library

In this below script, Item Adding / Item Added Event Receiver

Item Adding / Item Added Event Receiver In SharePoint
Ways to retrieve data are:

Properties.ListItem[«FieldName »]

Properties.AfterProperties[«FieldName »]

Properties.BeforeProperties[«FieldName »]


we must add the synchronization parameter


 to our xml definition.


<Receiver>
<Name>EventReceiver1ItemAdded</Name>
<Type>ItemAdded</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>TutoTaxonomy.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>
</Receiver>
In our code we add an update of the column “test”


public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
properties.ListItem["test"] = "test synchro";
properties.ListItem.Update();
}

Wednesday, December 9, 2015

To fix Add an App option in SharePoint 2013 "Apps you can add" is missing

Add the below lines in the MasterPage in SharePoint

<!--SPM:<SharePoint:AjaxDelta id="DeltaPlaceHolderLeftNavBar" BlockElement="true" runat="server">-->
<!--SPM:<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">-->
<!--SPM:</asp:ContentPlaceHolder>-->
<!--SPM:</SharePoint:AjaxDelta>-->
<!--SPM:<SharePoint:AjaxDelta id="DeltaPlaceHolderPageTitleInTitleArea" runat="server">-->
<!--SPM:<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">-->
<!--SPM:</asp:ContentPlaceHolder>-->
<!--SPM:</SharePoint:AjaxDelta>-->

Tuesday, March 17, 2015

how to create CRUD operation in SharePoint App in Client Object Model?

Add List item
how to create a custom properties in  user profile service application



Open to Central Adminstration->Application Management->Manage Service Applications-> Click on the User Profile Service Application.