Logged in UserName

K

Kalpana

Hi

I am trying to get the logged in user name: If I use
"System.Environment.UserName" in my C#.net code I get the person's id who
logged into the machine. I want to get the name of the SharePoint User. From
the Form Library an infopath form is filled. People get to the form library
with a specified UserId password, it does not have to be the same as the
machine logged in UserID. So when I try to use
"System.Security.Principal.WindowsIdentity.GetCurrent().Name" hoping it will
give me the sharepoint user - I get the System Access Denied. I actually got
the same for the System.Environment.UserName - and as soon as i added the
site to Local Intranet zone - it worked. But for the
System.Security.Principal.WindowsIdentity.GetCurrent().Name I still get the
error. I have few lines of code on the "OnSubmit" and "OnLoad" event. How can
I make this code fully trusted? Can I just make the code fully trusted and
not the form? If I do so will it solve this issue?

Thanks
Kalpana
 
D

darko

Hi, Kalpana,

You can make the Form fully trusted, but not only the beck-end code. If the
form is fully-trusted you can call the
System.Security.Principal.WindowsIdentity.GetCurrent().Name method, and you
will get the SharePoint logged user.

Darko Milevski, MCAD
 
K

Kalpana

Thanks for your reply. Which is the simplest way to make the form fully
trusted. I just want to do it once and publish it to the SharePoint. Is that
possible?
 
D

darko

In order to make form fully trusted, you save to sign it with a CodeSigning
digital signature. You can sign the form from the Tools -> Form Options ->
(tab) Security.
The uncheck the checkbox Automatically determine... , select Full Trust
radio butoon. Then check Sign this form on the bottom of the dialog box,
select the digital certificate and click OK. After this publish the form.

Every time you make a change in the code or the form, the Form must be
signed again and published.

Darko Milevski, MCAD
 
K

Kalpana

Hi Darko

Thanks for your reply. How do I get the certificate? Does it come with a
fee? Can you please point me to a site which has all this information.

Thanks
Kalpana
 
D

darko

Hi,

There are several sites where InfoPath tutorials can be found. One of them
is http://www.infopathdev.com/. For the digital signature issue here are some
articles on MSDN:
http://office.microsoft.com/en-us/infopath/CH011097171033.aspx and
http://msdn.microsoft.com/library/d...2003_ta/html/ODC_INFDigitallySigningData1.asp

You can make a digital signature with an office tool MAKECERT.EXE, or from a
Certificate Authority (on you’re company domain) or buy a third-party
certificate. This certificate must be added in trusted publishers on the
machine opening the signed form. So if you are using the form inside the
company, it is useful to sign the form with the Code Signing digital
certificate issued from the domain certificate authority, and add the
signature on the all corporate machines with a domain group policy. In other
way, when the user open the digitally signed form, if the certificate used
for signing the form is not in the users trusted publisher store, he will be
asked to confirm that he wants to use the certificate as trusted publisher.

Read the articles and you will learn all about the digital certificates in
InfoPath.

Darko Milevski, MCAD
 
K

Kalpana

Thank You!

darko said:
Hi,

There are several sites where InfoPath tutorials can be found. One of them
is http://www.infopathdev.com/. For the digital signature issue here are some
articles on MSDN:
http://office.microsoft.com/en-us/infopath/CH011097171033.aspx and
http://msdn.microsoft.com/library/d...2003_ta/html/ODC_INFDigitallySigningData1.asp

You can make a digital signature with an office tool MAKECERT.EXE, or from a
Certificate Authority (on you’re company domain) or buy a third-party
certificate. This certificate must be added in trusted publishers on the
machine opening the signed form. So if you are using the form inside the
company, it is useful to sign the form with the Code Signing digital
certificate issued from the domain certificate authority, and add the
signature on the all corporate machines with a domain group policy. In other
way, when the user open the digitally signed form, if the certificate used
for signing the form is not in the users trusted publisher store, he will be
asked to confirm that he wants to use the certificate as trusted publisher.

Read the articles and you will learn all about the digital certificates in
InfoPath.

Darko Milevski, MCAD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top