I have a page that will need to be able to write to the AD of another domain so requires logging in as another user when it runs that code.
I found this on the MSDN site
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = Me.User.Identity.Name
Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
currentWindowsIdentity = CType(User.Identity, System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()
'Insert your code that runs under the security context of the authenticating user here.
Label2.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name
impersonationContext.Undo()
End Sub
but do not understand where i am supposed to pass in the credentials of the user i wish to log in as.
also .impersonate seems to require a login type that i am at complete loss as to how to obtain.
if anyone could explain this i would be very greatful.
renrutxela
Member
8 Points
10 Posts
Elevated Security
Feb 26, 2013 10:56 AM|LINK
I have a page that will need to be able to write to the AD of another domain so requires logging in as another user when it runs that code.
I found this on the MSDN site
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Text = Me.User.Identity.Name Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity currentWindowsIdentity = CType(User.Identity, System.Security.Principal.WindowsIdentity) impersonationContext = currentWindowsIdentity.Impersonate() 'Insert your code that runs under the security context of the authenticating user here. Label2.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name impersonationContext.Undo() End Subbut do not understand where i am supposed to pass in the credentials of the user i wish to log in as.
also .impersonate seems to require a login type that i am at complete loss as to how to obtain.
if anyone could explain this i would be very greatful.
Alex.
Pengzhen Son...
Star
8162 Points
840 Posts
Microsoft
Re: Elevated Security
Feb 27, 2013 09:21 AM|LINK
Hi,
try enabling windows authention on both the sites. Make the following changes in the web.config.
http://msdn.microsoft.com/en-us/library/ff647405.aspx
http://forums.asp.net/t/1093048.aspx/2/10
And you can share the authentication cookie across multiple domains. Please refer here
http://www.codeproject.com/Articles/106439/Single-Sign-On-SSO-for-cross-domain-ASP-NET-applic
Hope it can help you.
Feedback to us
Develop and promote your apps in Windows Store