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>