After answering a forum post the other day where a person needed to have the logged in user’s name passed as a parameter to a data view, I realized my answer wasn’t common knowledge.
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…
2. Click New Parameter, name the parameter MyServerVar (or, whatever you like), and set the Parameter Source to be Server Variable.
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.
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 UR |
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.
|


I couldn’t understand some parts of this article t Know About at DataFormWebPart - Blog, but I guess I just need to check some more resources regarding this, because it sounds interesting.
Hey, if you have any specific questions let me know Daniel. The post is rather general, but needs to be for the context. I’d be happy to elaborate if needed.
-Monjo
I would like to make a site where all client users can log in to a site and add to the lists and discussions boards. However I want them to only see items added by thier group.
Is there a way to return what group the user is in?
@Chris: Not without tapping the object model. How many groups are there? If there is a static number, it may be easy to create separate lists and discussion boards for each group. Assign permissions on the lists to a specific group. This will security trim the lists and discussion boards out of the UI for any group that does not have access to it. Effectively accomplishing what you want.
Hello!
Is there any way to modify or update data via web service and sharepoint designer?
Thank you!
Is it possible to access a custom server variable declared inside a server script tag in the page?
Thanks for this! This really helps me for a project I’m working on. Do you know how to get the user’s friendly name into that parameter? For example, the LOGON_USER variable returns ‘DOMAIN\joe’ but I’d like to have it return ‘joe blow’
Great solution! I am using this to change an icon on a DVWP list ib a public facing site. If the REMOTE_USER is blank, I am displaying a lock and no URL to a section of the site. Otherwise, display the URL and a folder icon!
You write: “A fun trick to see what the server variable values actually are is to output them into your data view: ”
Could you please explain how to do, step by step? I’m qiute new to Sharepoint designer, and need even the basics explained…
Yes please give detailed steps on outputting in data view.
Nice article!
I have a doubt. Can we use a session variable as a parameter?
Thank you
-Arun
I’m trying to see if this is going to be helpful for a site we are developing. Basically when a user visits the site, it will check their IP and based off that display certain content. It appears to me that this should be possible with the IIS variables listed.
I’m having trouble setting this up. I’ve added the Dataview Webpart in SPD, but I’m not seeing the Common Tasks pane. Any advise?
eric