Partager via


Data View / Data Form: Parameters You Don’t Know About

From my old blogging site DataFormWebPart.com, this post continues to garner good amounts of traffic. Like in a previous blog entry, I am lifting my old post to put on here in hopes of it getting more visibility and use.

There is a collection of variables called ServerVariables that can access all of the IIS server variables. There are a lot of useful ones, and you can use these variables in your data view / form web parts as parameters.

Here are the basic steps access the variables:

1. On the Common Data View Tasks pane on your data view web part, click Parameters…

image

2. Click New Parameter, name the parameter MyServerVar (or, whatever you like), and set the Parameter Source to be Server Variable.

image

3. In Server Variable Name, enter in any of the available server variables (listed below). For sake of example, I am going to use LOGON_USER.

image

4. That’s it! Now MyServerVar can be used as a parameter in the data view / form web part. Use it to filter, sort, etc.

Here is a list of Server Variables you can use:

Variable Description
ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAW Returns all headers in raw form
APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path
AUTH_PASSWORD Returns the value entered in the client’s authentication dialog
AUTH_TYPE The authentication method that the server uses to validate users
AUTH_USER Returns the raw authenticated user name
CERT_COOKIE Returns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUER Returns the issuer field of the client certificate
CERT_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZE Returns the number of bits in server certificate private key
CERT_SERIALNUMBER Returns the serial number field of the client certificate
CERT_SERVER_ISSUER Returns the issuer field of the server certificate
CERT_SERVER_SUBJECT Returns the subject field of the server certificate
CERT_SUBJECT Returns the subject field of the client certificate
CONTENT_LENGTH Returns the length of the content as sent by the client
CONTENT_TYPE Returns the data type of the content
GATEWAY_INTERFACE Returns the revision of the CGI specification used by the server
HTTP_<HeaderName> Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENT Returns a string describing the browser that sent the request
HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key
HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate
HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate
INSTANCE_ID The ID for the IIS instance in text format
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request
LOCAL_ADDR Returns the server address on which the request came in
LOGON_USER Returns the Windows account that the user is logged into
PATH_INFO Returns extra path information as given by the client
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRING Returns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
REQUEST_METHOD Returns the method used to make the request
SCRIPT_NAME Returns a virtual path to the script being executed
SERVER_NAME Returns the server’s host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORT Returns the port number to which the request was sent
SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL

Source or read more about it on MSDN.

Note: A fun trick to see what the server variable values actually are is to output them into your data view: <xsl:value-of select=”$MyServerParam” />

Now whenever you change Server Variable Name (ex: LOGON_USER to AUTH_TYPE) the value will be reflected in your data view.

Comments

  • Anonymous
    July 27, 2008
    PingBack from http://stevepietrek.com/2008/07/27/links-7272008/

  • Anonymous
    August 11, 2008
    Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  • Anonymous
    August 11, 2008
    Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  • Anonymous
    August 12, 2008
    Hier habe ich ein paar Tipps zum SharePoint Designer zusammengestellt: Use SharePoint Designer to Email

  • Anonymous
    August 14, 2008
    Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

  • Anonymous
    August 14, 2008
    Direkter Download: SPPD-102-2008-08-14 Aktuell Feedback Usergruppen ISPA International SharePoint Professionals

  • Anonymous
    August 14, 2008
    This came in perfect time. Just what I needed and exactly when I needed it. :)

  • Anonymous
    October 06, 2008
    Please get this info added to the SPD Help File. Having to search the internet for this type of information is a lot of extra work for users that could be prevented by adding a link in the Help file to this blog posting or section of the IIS help file. Thanks

  • Anonymous
    October 14, 2008
    The comment has been removed

  • Anonymous
    October 15, 2008
    one more thing about querystrings... in order to send more than 1 variable from the XSLT data view, i had to use the html special var  "&amp;" instead of "%26"

  • Anonymous
    April 07, 2009
    I have multiple subsites in my site collection.  Each subsite is for a different group but all share the same lists.  To prevent one office from seeing another office's information I want to filter by sitename.  Is this possible?  

  • Anonymous
    January 07, 2010
    How can I get the user's email address?

  • Anonymous
    January 10, 2010
    hi, i am facing filtering/sorting issue. it is throwing javacript error. please help me

  • Anonymous
    January 15, 2010
    Once I have the server variable how do I go about passing that value.  For example I would like to send the value of the variable to a web service to perform a database query based on the value.

  • Anonymous
    February 18, 2010
    Hi How do i set the dataview parameter to a column in the lst?

  • Anonymous
    September 12, 2010
    The comment has been removed

  • Anonymous
    December 23, 2013
    good post to know how we can use server variables