Unable to connect to SharePoint Online from CSOM Application

%3CLINGO-SUB%20id%3D%22lingo-sub-991120%22%20slang%3D%22en-US%22%3EUnable%20to%20connect%20to%20SharePoint%20Online%20from%20CSOM%20Application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-991120%22%20slang%3D%22en-US%22%3E%3CP%3EUsing%20CSOM%20Application%2C%20I%20am%20tried%20to%20connect%20Office%20365%20SharePoint%20Online%20Portal.For%20Office%20365%20single%20sign-on%20Authentication%2C%20Active%20Directory%20Federation%20Services%20(ADFS)%20is%20configured.I%20tried%20to%20connect%20using%20the%20APP%20Password%20as%20well%20AD%20Login%20Password.%20Both%20are%20not%20working.%20Please%20advise.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1015812%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20to%20connect%20to%20SharePoint%20Online%20from%20CSOM%20Application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1015812%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F113593%22%20target%3D%22_blank%22%3E%40Sajith%20G%20H%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Edid%20you%20tried%20use%20%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FSharePointPnPCoreOnline%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ESharePoint%20PnP%20Core%20Online%20nuget%20package%3C%2FA%3E%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20could%20use%26nbsp%3B%3CEM%3EAuthenticationManager.GetADFSUserNameMixedAuthenticatedContext%3C%2FEM%3E%20method%2C%20something%20like%20this%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Evar%20siteUrl%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%3C%2FA%3E%22%3B%20%20%0Avar%20userName%20%3D%20%22username%22%3B%20%20%0Avar%20password%20%3D%20GetSecureString(%22password%22)%3B%20%20%0Avar%20domain%20%3D%20%22domain%22%3B%20%20%0AAuthenticationManager%20authManager%20%3D%20new%20AuthenticationManager()%3B%20%20%0AClientContext%20context%20%3D%20authManager.GetADFSUserNameMixedAuthenticatedContext(siteUrl%2C%20userName%2C%20password%2C%20%22sts.company.com%22%2C%20%22idpId%22)%3B%0A%0A%20%20%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%2C%20check%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fofficedevpnp.core.authenticationmanager.getadfsusernamemixedauthenticatedcontext%3Fview%3Dsharepointpnpcoreonline-2.18.1709.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eofficial%20docs%3C%2FA%3E%20in%20order%20to%20understand%20better%20all%20method%20parameters.%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Using CSOM Application, I am tried to connect Office 365 SharePoint Online Portal.For Office 365 single sign-on Authentication, Active Directory Federation Services (ADFS) is configured.I tried to connect using the APP Password as well AD Login Password. Both are not working. Please advise.

1 Reply

Hi @Sajith G H 

did you tried use SharePoint PnP Core Online nuget package?

 

You could use AuthenticationManager.GetADFSUserNameMixedAuthenticatedContext method, something like this 

 

var siteUrl = "<a href="https://tenant.sharepoint.com" target="_blank">https://tenant.sharepoint.com</a>";  
var userName = "username";  
var password = GetSecureString("password");  
var domain = "domain";  
AuthenticationManager authManager = new AuthenticationManager();  
ClientContext context = authManager.GetADFSUserNameMixedAuthenticatedContext(siteUrl, userName, password, "sts.company.com", "idpId");

   

 

Please, check official docs in order to understand better all method parameters.

Cheers,

Federico