if (Logging.authorityConnectors.isDebugEnabled()){
Logging.authorityConnectors.debug("SharePoint authority: getUserInfo xml response: '" + usersList[0].toString() + "'");
}
MessageElement users = usersList[0];
if (!users.getElementName().getLocalName().equals("GetUserInfo"))
throw new ManifoldCFException("Bad response - outer node should have been 'GetUserInfo' node");
String userID = null;
String userName = null;
Iterator userIter = users.getChildElements();
while (userIter.hasNext())
{
MessageElement child = (MessageElement)userIter.next();
if (child.getElementName().getLocalName().equals("User"))
{
userID = child.getAttribute("ID");
userName = child.getAttribute("LoginName");
}
}
// If userID is null, no such user
if (userID == null)
return null;
List<String> accessTokens = new ArrayList<String>();
accessTokens.add("U"+userName);
com.microsoft.schemas.sharepoint.soap.directory.GetGroupCollectionFromUserResponseGetGroupCollectionFromUserResult userGroupResp =
userCall.getGroupCollectionFromUser( userLoginName );
org.apache.axis.message.MessageElement[] groupsList = userGroupResp.get_any();
/* Response looks like this:
<GetGroupCollectionFromUser xmlns=
"http://schemas.microsoft.com/sharepoint/soap/directory/">
<Groups>
<Group ID="3" Name="Group1" Description="Description" OwnerID="1"
OwnerIsUser="False" />
<Group ID="15" Name="Group2" Description="Description"
OwnerID="12" OwnerIsUser="True" />
<Group ID="16" Name="Group3" Description="Description"
OwnerID="7" OwnerIsUser="False" />
</Groups>
</GetGroupCollectionFromUser>
*/
if (groupsList.length != 1)
throw new ManifoldCFException("Bad response - expecting one outer 'GetGroupCollectionFromUser' node, saw "+Integer.toString(groupsList.length));
if (Logging.authorityConnectors.isDebugEnabled()){
Logging.authorityConnectors.debug("SharePoint authority: getGroupCollectionFromUser xml response: '" + groupsList[0].toString() + "'");
}
MessageElement groups = groupsList[0];
if (!groups.getElementName().getLocalName().equals("GetGroupCollectionFromUser"))
throw new ManifoldCFException("Bad response - outer node should have been 'GetGroupCollectionFromUser' node");
Iterator groupsIter = groups.getChildElements();
while (groupsIter.hasNext())
{
MessageElement child = (MessageElement)groupsIter.next();
if (child.getElementName().getLocalName().equals("Groups"))
{
Iterator groupIter = child.getChildElements();
while (groupIter.hasNext())
{
MessageElement group = (MessageElement)groupIter.next();
if (group.getElementName().getLocalName().equals("Group"))
{
String groupID = group.getAttribute("ID");
String groupName = group.getAttribute("Name");
// Add to the access token list
accessTokens.add("G"+groupName);
}
}
}
}
// AxisFault is expected for case where user has no assigned roles
try
{
com.microsoft.schemas.sharepoint.soap.directory.GetRoleCollectionFromUserResponseGetRoleCollectionFromUserResult userRoleResp =
userCall.getRoleCollectionFromUser( userLoginName );
org.apache.axis.message.MessageElement[] rolesList = userRoleResp.get_any();
if (rolesList.length != 1)
throw new ManifoldCFException("Bad response - expecting one outer 'GetRoleCollectionFromUser' node, saw "+Integer.toString(rolesList.length));
if (Logging.authorityConnectors.isDebugEnabled()){
Logging.authorityConnectors.debug("SharePoint authority: getRoleCollectionFromUser xml response: '" + rolesList[0].toString() + "'");
}
// Not specified in doc and must be determined experimentally
/*
<ns1:GetRoleCollectionFromUser xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/directory/">
<ns1:Roles>
<ns1:Role ID="1073741825" Name="Limited Access" Description="Can view specific lists, document libraries, list items, folders, or documents when given permissions."
Order="160" Hidden="True" Type="Guest" BasePermissions="ViewFormPages, Open, BrowseUserInfo, UseClientIntegration, UseRemoteAPIs"/>
</ns1:Roles>
</ns1:GetRoleCollectionFromUser>'
*/
MessageElement roles = rolesList[0];
if (!roles.getElementName().getLocalName().equals("GetRoleCollectionFromUser"))
throw new ManifoldCFException("Bad response - outer node should have been 'GetRoleCollectionFromUser' node");
Iterator rolesIter = roles.getChildElements();
while (rolesIter.hasNext())
{
MessageElement child = (MessageElement)rolesIter.next();
if (child.getElementName().getLocalName().equals("Roles"))
{
Iterator roleIter = child.getChildElements();
while (roleIter.hasNext())
{
MessageElement role = (MessageElement)roleIter.next();
if (role.getElementName().getLocalName().equals("Role"))
{
String roleID = role.getAttribute("ID");
String roleName = role.getAttribute("Name");
// Add to the access token list
accessTokens.add("R"+roleName);
}
}
}