javascript and ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AnuSumesh
    New Member
    • Aug 2007
    • 96

    javascript and ASP

    Hi All,

    I have some asp code that is using dll shareaccessext. dll and its methods via creaing its object. My code is as follows:
    Code:
    funcion getobj()
    {
    var obj = null;
    	var x = Request.ServerVariables("AUTH_TYPE"), 
    		apppath = Request.ServerVariables("APPL_PHYSICAL_PATH").Item;
    
    	var xHeaderName,xHeaderValue = "";
    	var xHeaderPass  = "";
    	var bHasPassword = true;
    
    	var isBasicAuth = (x == "Basic"), useBasicAuth = 0;
    	var isAdminSite = (apppath.indexOf("\\AdmPages") > 0);
    	try {
    		obj = new ActiveXObject("ShareAccess.ShareEnum");
    		obj.SetSiteData(Request.ServerVariables("SERVER_NAME"), Request.ServerVariables("LOCAL_ADDR") ,Request.ServerVariables("SERVER_PORT"));
    		useBasicAuth = obj.BasicAuth((isAdminSite) ? 1 : 2);
    		xHeaderName = obj.HeaderName;
    	}
    	catch (e)
    	{
    		useBasicAuth = -1;
    		xHeaderName = "";
    	}
    
    	if(obj == null)
    	{
    		Response.Redirect("/InternalSite/InternalError.asp?error_code=201")
    		return null;
    	}
    
    	if(useBasicAuth && isBasicAuth) {
    		xHeaderValue = new String(Request.ServerVariables("REMOTE_USER"));
    		xHeaderPass  = new String(Request.ServerVariables("AUTH_PASSWORD"));
    	}
    	else if(x != "") //if not anonymous logon - use the iis impersonation
    	{
    		xHeaderValue = new String(Request.ServerVariables("REMOTE_USER"));
    		xHeaderPass  = new String("whl_dummy_ntlm_password");
    	}
    	else if(xHeaderName != "") {
    		xHeaderValue = new String(Request.ServerVariables(xHeaderName).Item);
    		bHasPassword = false;
    	}
    	else {
    		xHeaderValue = new String(Request.ServerVariables("REMOTE_USER"))
    	}
    
    	try {
    		obj.SetSecurityInfo("FileAccess", Request.ServerVariables("HTTPS"), Request.ServerVariables("REQUEST_METHOD"));
    		if (bHasPassword == true) {
    			Retval = obj.SetUserDataFromHeaderUserPass(xHeaderValue, xHeaderPass);
    		}
    		else {
    			Retval = obj.SetUserDataFromHeader(xHeaderValue);
    		}
    
    		if(!Retval){
    			var i = xHeaderValue.indexOf(':');
    			if(i <= 0)i = xHeaderValue.length;
    //			Response.Write("Error logging on user " + xHeaderValue.substr(0,i));
    			if (apppath.indexOf("e-Gap")!=-1)
    				Response.Write("Error logging on user " + xHeaderValue.substr(0,i) + " - Wrong Credentials Supplied.");
    			else
    				Response.Write("Error logging on user " + xHeaderValue.substr(0,i) + " - Possible Misconfiguration Problem.");
    			Response.End();
    		}
    	}
    	catch(e){
    		Response.Write("Error " + e);
    		Response.End();
    	}
    
    	apppath = Request.ServerVariables("PATH_INFO").Item;
    	if(isAdminSite && (apppath.indexOf("novell_nt_login.asp") < 0) && !obj.IsAdminUser){
    		Response.Write("You have no permissions to configure Secure File Access Application.");
    		obj = null;
    		Response.End();
    	}
    
    	return obj;
    }
    One exe file is also present in same folder as dll file and asp file.

    The dll shareaccessext. dll is at server side.
    This code is executed when clien access webpage from browser.
    I am geting confused how javascript can access serverside dll file and its methods.

    Its urgent plzzzzz

    Thanks n Regards
    Anu
    Last edited by JamieHowarth0; Oct 21 '08, 03:04 PM. Reason: Added code tags
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Hi Anu,

    Please remember to use [ CODE] and [/ CODE] tags in future around your code (remove the spaces).

    Is the above code Javascript? It looks like it contains parts of ASP code in there (Request.Querys tring), which wouldn't work in the way that you are using them.

    If you've created a DLL and it resides on the server, to get it to interact with Javascript would require the use of AJAX to call server-side code to manipulate an instance of the DLL (which would either have to be an ActiveX object or a COM+ object). You can't get Javascript to execute stuff on the server on it's own, it's a purely client-side scripted programming language.

    Hope this helps.

    codegecko

    Comment

    • AnuSumesh
      New Member
      • Aug 2007
      • 96

      #3
      Hi

      I am agree with you.
      Its not my code. Actually i have to understand this code and need to copy some of the methods of dll used in this code.
      I am also confused, b'coz javascript can't be used for server side programming.

      Files are on server side. Same folder contains one dll, one exe and asp programs.
      The code that i posted is part of asp file. I am guessing javascript As its using javascript syntax. No ajax is used here.

      Can you plz explain me which language is used here in asp?
      I doubt if its JSP syntax.I am totally confused as pages are saved as .asp and is using some java syntax for server side coding.
      Plzzzzzzzz help me.

      Regards,
      Anu
      Last edited by AnuSumesh; Oct 22 '08, 05:23 AM. Reason: providing more information

      Comment

      • AnuSumesh
        New Member
        • Aug 2007
        • 96

        #4
        Sorry I go it.
        Its using jscript as server side scripting in asp pages.

        Thanks a lot

        Anu

        Comment

        • JamieHowarth0
          Recognized Expert Contributor
          • May 2007
          • 537

          #5
          Taking a look over your code, I was going to suggest that it might be JScript but I wasn't too sure so I thought I'd ask if there was any AJAX involved to clear up any ambiguity.

          Anyways, I'm glad to hear you got it sorted :-)

          codegecko

          Comment

          Working...