Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AD Security and query infoobjects 1

Status
Not open for further replies.

johneydluca

Programmer
May 29, 2002
25
US
Hi,
I am a new developer on using CE. I am implementing a security for reporting portal. I am using asp.net to create
portal.
How would I query infoobjects sing AD Security and get the list of reports that user has access?

Thanks

jd
 
Hi,
Look at the docs on creating an InfoStore and then querying the CI_INFOOBJECTS data after authenticating the user:
Here's is one sample( JavaScript) of 2 functions that can be called.

Code:
function RetrieveIStore() 
{ 
//Precondition: None

//Postcondition:
//Returns the InfoStore object that allows you to query the server.

//The function returns null if it does not succeed. 

	var LogonToken;
	var SessionManager;
	var Sess;
	
	// Check to see if the cookie is there
		if (GetCookie("LogonToken") == "" ) {
	  		
		    	 Response.Write ("<BR>Problem logging in to Crystal Server");
		    	 return(null);
	  		}
		

	//Try to retrieve the cookie.
	LogonToken = GetCookie("LogonToken");
	
	//Check to see if a logon token was really retrieved.
	if( LogonToken != "" ) 
	{
			
		//Check to see if the InfoStore already exists.
		
			//Create a session manager.
			SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr");
						
			//Logon using the token. This may fail if the token is no longer valid.
			Sess = SessionManager.LogonWithToken(LogonToken);
						
			//Create the InfoStore object.
			IStore = Sess.Service("", "InfoStore");

			//Save the InfoStore in the session.
			SetSession("IStore",IStore);
			return (IStore);
		}
		
	
    }
    	
function RetrieveReports(ParentID ,IStore) 
{
//This returns an HTML table that is populated with the report name,
//report description, and the last time it was modified.

//Precondition:
//ParentID - The ID of the parent folder containing the reports to be retrieved.
//IStore - The InfoStore object required to interface with server.


//Postcondition:
//Returns an empty string if there are no reports, null if an error occurred, and
//the string if successful.

//Notes:
//The function returns a string that is an HTML table. 
	//The query that will select the reports.
	var Query;  
	//The result of the query.
	var Result;
	//A string to hold the HTML table.
	var HTMLTable; 
	HTMLTable="";

	//Create a query that selects all the reports, but doesn't select the instances.
	Query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " +
	"SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" + ParentID +
	"ORDER BY SI_DESCRIPTION";
		
		
	//Query the server.
	try {
		Result = IStore.Query(Query) ;
	}
	catch(e) {
		return null;
	}
	 
   
	if (Result.Count > 0) {
		//Set up the table header.
		HTMLTable="<TABLE width = \"800\" >" +
		"<TR><TH align='left'><B></B></TH>" +
		"<TH align='left'><B></B></TH></TR>"; 
				
		for (k=1;k<=Result.Count;k++)
		//Add the report name and details to the table.	
		{ 
		         if (Result.Item(k).Description == "") {
			var desc1 = Result.Item(k).Title;
			}
			else {
			var desc1 = Result.Item(k).Description;
			}
			var desc = Result.Item(k).Description
			//var descSize = desc.length - 1;
			//var descDisplay = desc.substr(3,descSize);
			HTMLTable=HTMLTable +
				"<TR  valign=top><TD>" + 
				"<A   class='tableLink' title='Report Name: " + Result.Item(k).Title + "' HRef='#' onClick=\"navReport('" + Result.Item(k).ID +"')\">" +
				Server.HTMLEncode(desc1) + "</A></TD>" ;
		} 
		HTMLTable=HTMLTable+"</TABLE>";
	}
	    
	return( HTMLTable);
}


Hope it provides some ideas..


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Turkbear
THanks a lot for the quick reply. This was a helpful. How can I referance object CrystalEnterprise.SessionMgr . I mean which .Net DLL should be selected from Project-->AddReferances?
Also don't I need to refer name of AD somewhere? Can I refer AD because same user may have access to report in some other application and I want list of report in my application.


Thanks
 
Turkbear
Those documents were helpful. One more question for the day - How would you query CI_INFOOBJECTS and get list of reports under specific folder?

Thanks
jd
 
Hi,
Here is one way to call it and produce an HTML table with 'clickable' links that can be used to call functions that will run the report - you need to pass it the FolderID of the desired folder and the pre-established Infostore object Note: This query also returns the last modified time, but we are not currently using it - we adapted this code from CE examples and just left it in the query for future use :

Code:
function RetrieveReports(ParentID ,IStore) 
{
//This returns an HTML table that is populated with the report name,
//report description, and the last time it was modified.

//Precondition:
//ParentID - The ID of the parent folder containing the reports to be retrieved.
//IStore - The InfoStore object required to interface with server.


//Postcondition:
//Returns an empty string if there are no reports, null if an error occurred, and
//the string if successful.

//Notes:
//The function returns a string that is an HTML table. 
	//The query that will select the reports.
	var Query;  
	//The result of the query.
	var Result;
	//A string to hold the HTML table.
	var HTMLTable; 
	HTMLTable="";

	//Create a query that selects all the reports, but doesn't select the instances.
	Query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " +
	"SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" + ParentID +
	"ORDER BY SI_DESCRIPTION";
		
		
	//Query the server.
	try {
		Result = IStore.Query(Query) ;
	}
	catch(e) {
		return null;
	}
	 
   
	if (Result.Count > 0) {
		//Set up the table header.
		HTMLTable="<TABLE width = \"800\" >" +
		"<TR><TH align='left'><B></B></TH>" +
		"<TH align='left'><B></B></TH></TR>"; 
				
		for (k=1;k<=Result.Count;k++)
		//Add the report name and details to the table.	
		{ 
		         if (Result.Item(k).Description == "") {
			var desc1 = Result.Item(k).Title;
			}
			else {
			var desc1 = Result.Item(k).Description;
			}
			var desc = Result.Item(k).Description
			//var descSize = desc.length - 1;
			//var descDisplay = desc.substr(3,descSize);
			HTMLTable=HTMLTable +
				"<TR  valign=top><TD>" + 
				"<A   class='tableLink' title='Report Name: " + Result.Item(k).Title + "' HRef='#' onClick=\"navReport('" + Result.Item(k).ID +"')\">" +
				Server.HTMLEncode(desc1) + "</A></TD>" ;
		} 
		HTMLTable=HTMLTable+"</TABLE>";
	}
	    
	return( HTMLTable);
}


There are other ways as well, but the basic Query will be the same.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,
Sorry about duplicating the Code segment..I had not looked at my previous post to see that I had included the RetreiveReports function along with the InfoStore one - it was a cut/paste job and I cut more than I thought..
( I only write,I do not read [reading] what I write [blush])



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top