Get User IP & WorkStation Name in InfoPath Form

How To Get The IP Address & WorkStation Name of the user opening and InfoPath Form

Create an OnLoad Event

// Get PC Name and IP Address of current user
XPathNavigator root = MainDataSource.CreateNavigator();
//Get the values
string MyComputerName = root.SelectSingleNode("", NamespaceManager).Value;
string MyIPAddress = root.SelectSingleNode("/", NamespaceManager).Value;
string OS = root.SelectSingleNode("/", NamespaceManager).Value;
root.SelectSingleNode("/", NamespaceManager).SetValue(System.Environment.MachineName);
root.SelectSingleNode("/", NamespaceManager).SetValue(HttpContext.Current.Request.UserHostAddress);
root.SelectSingleNode("/", NamespaceManager).SetValue(System.Environment.OSVersion.ToString());
catch (Exception ex)
NotifyHost("The following error occured: " + ex.Message.ToString());


  1. Hi, Great post! I've spent quite some time looking for exactly this code, but I'm having some trouble with trying to implement this:

    HTTPContext is null at the time I try to reference Current.Request.UserHostAddress.

    Any ideas?



Post a Comment