I'm doing the same thing, using C# code to populate a text box with the user id. I get the user id when I preview the form, but when I publish the form to a Shrepoint form library it doesn't populate the user id. I don't get any security warnings or errors, and I'm not sure what I need to do to get it to work.