1

enter image description here

Hi, i am using client object model in c# win form. How to programmatically check if the current SharePoint user name and password is correct?

here I log in using SharePoint Site URL, username and Password. if User name or Password is Wrong then Log-in Process will be cancelled. how can i do this??

1
  • 1
    The screenshot of your login dialog is not useful, but code of what you've tried so far would be.
    – lgaud
    Commented Oct 8, 2013 at 15:37

1 Answer 1

2

I presume you mean a SharePoint 2010 forms authentication site where userid and password are to be provided. Check the code snippet below - you'll have to check exception value below and handle the exception accordingly (cancel login, etc). See the FormsAuthenticationLoginInfo class for more info.

try {
ClientContext fooCtx = new ClientContext(fooSiteUrl); 
fooCtx.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication; 
fooCtx.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo(fooUserName, fooUserPwd); 
}
catch (Exception fooE) {... }
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.