J'essaie de me connecter à un serveur Sharepoint via du code Java. Mon code fonctionne correctement avec certains serveurs Sharepoint, mais échoue lorsque j'essaie de me connecter à mon compte fourni par Comcast. Les classes ListsSoap
et Lists
ont été générées à partir d'un fichier WSDL Sharepoint à l'aide de wsimport. J'ai lu ceci peut être provoqué en n'utilisant pas doman \ nom d'utilisateur en tant que nom d'utilisateur de SharePoint. J'ai essayé de préfixer différents domaines au paramètre de nom d'utilisateur, des choses comme mycompany.comcastbiz.net\\[email protected]
, mais j'ai reçu une erreur 401 pour tous les noms de domaine que j'ai essayés.La tentative de récupération de Sharepoint WSDL échoue avec "Serveur redirigé trop de fois"
BasicHTTPAuthenticator auth = new BasicHTTPAuthenticator("[email protected]", password);
Authenticator.setDefault(auth);
Lists listsService = new com.microsoft.schemas.sharepoint.soap.Lists();
listsSoap = listsService.getListsSoap12();
import java.net.Authenticator;
import java.net.PasswordAuthentication;
class BasicHTTPAuthenticator extends Authenticator
{
private String userName;
private String password;
public BasicHTTPAuthenticator(String userName, String password)
{
this.userName = userName;
this.password = password;
}
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(userName, password.toCharArray());
}
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
}
public class Lists extends Service
{
private final static URL LISTS_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.microsoft.schemas.sharepoint.soap.Lists.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.microsoft.schemas.sharepoint.soap.Lists.class.getResource(".");
url = new URL(baseUrl, SharepointService.getServerUrl()+"/_vti_bin/Lists.asmx?WSDL");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: " + SharepointService.getServerUrl()+"/_vti_bin/Lists.asmx?WSDL");
logger.warning(e.getMessage());
}
LISTS_WSDL_LOCATION = url;
}
public Lists() {
super(LISTS_WSDL_LOCATION, new QName("http://schemas.microsoft.com/sharepoint/soap/", "Lists"));
}
...
}
Il a échoué avec:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.po1.comcast.net/sites/mycompany//_vti_bin/Lists.asmx?WSDL.
Server redirected too many times (20).
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:162)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:144)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:265)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:228)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:176)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
mycompany.comcastbiz.net \ [email protected] n'est certainement pas le bon formulaire. Il existe deux formes d'informations d'identification de l'authentificateur pour Windows: 1) UPN qui ressemble à une adresse e-mail utilisateur @ quelque chose, mais qui n'a pas besoin d'être corrélé avec l'adresse e-mail ou le domaine FQDN Active Directory . Ou Domain \ samAccountName - samAccountName est un nom d'utilisateur d'identification, il n'a certainement pas de @, n'a pas nécessairement de corrélation avec vpn, etc. Est dans LDAP sous l'attribut samAccountName – MJB