To query for ALI objects from a remote application, use the IObjectManager interface in the PRC.
Java:
public static voidqueryObjects(String loginToken) { IObjectManager objectManager = getSession(loginToken).getObjectManager(ObjectClass.User); int folderID = -1; //search all folders int startRow = 0; //start at the first found int maxRows = -1; //return unlimited results ObjectProperty sortProperty = UserProperty.UniqueName; //sort on the unique name boolean ascending = true; //sort ascending ObjectProperty[] propsToReturn = new ObjectProperty[4]; //return specific properties propsToReturn[0] = UserProperty.SimpleName; propsToReturn[1] = UserProperty.UniqueName; propsToReturn[2] = UserProperty.AuthName; propsToReturn[3] = ObjectProperty.Created; QueryFilter[] filters = new QueryFilter[2]; //filter the results //simple name contains "user" filters[0] = new StringQueryFilter(UserProperty.SimpleName, Operator.Contains,"user"); //created at most a day ago GregorianCalendar filterDate = new GregorianCalendar(); filterDate.add(Calendar.DATE, -1); Date yesterday = filterDate.getTime(); filters[1] = new DateQueryFilter(ObjectProperty.Created, Operator.GreaterThan, yesterday); try { IObjectQuery queryResults = objectManager.queryObjects( folderID, startRow, maxRows, sortProperty, ascending, propsToReturn, filters); for(int i = 0; i < queryResults.getRowCount(); i++) { IObjectQueryRow queryObject = queryResults.getRow(i); System.out.println( "User: " + queryObject.getStringValue(UserProperty.SimpleName) + ", Created:" + queryObject.getCreated()); } } catch(Exception e) { System.err.println(e.getMessage()); e.printStackTrace(System.err); } }
.NET (C#):
public static voidQueryObjects(stringloginToken) { IObjectManager objectManager = GetSession(loginToken).GetObjectManager(ObjectClass.User); int folderID = -1; //search all folders int startRow = 0; //start at the first found int maxRows = -1; //return unlimited results ObjectProperty sortProperty = UserProperty.UniqueName; //sort on the unique name bool ascending = true; //sort ascending ObjectProperty[] propsToReturn = new ObjectProperty[4]; //return specific properties propsToReturn[0] = UserProperty.SimpleName; propsToReturn[1] = UserProperty.UniqueName; propsToReturn[2] = UserProperty.AuthName; propsToReturn[3] = ObjectProperty.Created; DateTime yesterday = new DateTime(); yesterday = DateTime.Now.AddDays(-1); QueryFilter[] filters = new QueryFilter[2]; //filter the results //simple name contains "user" filters[0] = new StringQueryFilter(UserProperty.SimpleName, Operator.Contains, "user"); //created at most a day ago filters[1] = new DateQueryFilter(ObjectProperty.Created, Operator.GreaterThan, yesterday); try { IObjectQuery queryResults = objectManager.QueryObjects( folderID, startRow, maxRows, sortProperty, ascending, propsToReturn, filters); for(int i = 0; i < queryResults.GetRowCount(); i++) { IObjectQueryRow queryObject = queryResults.GetRow(i); Console.Out.WriteLine( "User: " + queryObject.GetStringValue(UserProperty.SimpleName) + ", Created:" + queryObject.GetCreated()); } } catch(Exception e) { Response.Write(e.Message + "<br>"); Response.Write(e.StackTrace + "<br><br>"); } }
.NET (VB):
Public Shared SubQueryObjects(ByVal loginToken As String) Dim objectManager As IObjectManager Dim session As IRemoteSession = portletContext.GetRemotePortalSession objectManager = session.GetObjectManager(ObjectClass.User) Dim folderID As Integer folderID = -1 'search all folders Dim startRow As Integer startRow = 0 'start at the first found Dim maxRows As Integer maxRows = -1 'return unlimited results Dim sortProperty As ObjectProperty sortProperty = UserProperty.UniqueName 'sort on the unique name Dim ascending As Boolean ascending = True 'sort ascending Dim propsToReturn(4) As ObjectProperty 'return specific properties propsToReturn(0) = UserProperty.SimpleName propsToReturn(1) = UserProperty.UniqueName propsToReturn(2) = UserProperty.AuthName propsToReturn(3) = ObjectProperty.Created Dim yesterday As DateTime yesterday = DateTime.Now.AddDays(-1) Dim filters(2) As QueryFilter 'filter the results 'simple name contains "user" filters(0) = New StringQueryFilter(UserProperty.SimpleName, _Operator.Contains, _"user") 'created at most a day ago filters(1) = New DateQueryFilter(ObjectProperty.Created, _Operator.GreaterThan, yesterday) Try Dim queryResults As IObjectQuery queryResults = objectManager.QueryObjects(folderID, startRow, maxRows, sortProperty, ascending, propsToReturn, filters) Dim i As Integer Dim queryObject As IObjectQueryRow For i = 0 To queryResults.GetRowCount()-1 queryObject = queryResults.GetRow(i) Response.Write(_ "User: " & queryObject.GetStringValue(UserProperty.SimpleName)& _ ", Created:" & queryObject.GetCreated() + "<br>") Next Catch e As Exception Response.Write(e.Message + "<br>") Response.Write(e.StackTrace) End Try EndSub