EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB12322: How to search for a User Object based on Login ID using the MicroStrategy Java Web SDK


Community Admin

• Strategy


This article discusses how to search for a User Object based on Login ID using the MicroStrategy Java Web SDK 9.x and 10.x

When writing customizations using the Strategy Java Web SDK, there may be a need to locate a user based on their login ID. This technical document will clarify the process to create a WebSearch object that will locate a user based on their login ID.
 
The WebSearch object is the main tool for searching the metadata. The code below searches the metadata for a user with a given login ID, searchString:
 
WebSearch webSearch=objectSource.getNewSearchObject();
webSearch.setSearchFlags(EnumDSSXMLSearchFlags.DssXmlSearchNameWildCard+EnumDSSXMLSearchFlags.DssXmlSearchRootRecursive);
//Use a simple list to restrict the search to only User Objects
SimpleList searchTypes = webSearch.types();
Integer type=new Integer(EnumDSSXMLObjectTypes.DssXmlTypeUser);
searchTypes.add(type);
//Note: Use the Abbreviation Pattern, not the Name Pattern to search on Login ID
webSearch.setAbbreviationPattern(searchString);
//set the Domain to search the entire Repository
webSearch.setDomain( EnumDSSXMLSearchDomain.DssXmlSearchDomainRepository );
webSearch.setAsync(false);
WebObjectInfo objectInfo = null;
//Execute the search
try {
webSearch.submit();
if (webSearch.getResults().isEmpty())
System.out.println("No user by name "+searchString);
else {
objectInfo = webSearch.getResults().get(0);
System.out.println("Found user: " + objectInfo.getDisplayName());
}
}
catch (Exception e){
System.out.println("Search failed: "+e);
}
To create a WebSearch object, the user simply needs to insert the following line in any java class where they are using Strategy objects:
 
WebSearch webSearch=objectSource.getNewSearchObject();
There are two ways that the above code varies from a standard search:
 

  1. The search restricts itself to objects of type User. This is done by adding integer objects to SimpleList websearch.types().
  2. The search must use the setAbbreviationPattern() method, not the setNamePattern() method. This is because the Login ID is stored in the abbreviation field of WebObjectInfo. The full name is stored in the name field.

Customization Warning:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 14, 2017

Last Updated:

June 14, 2017