15,885,757 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by sanjayv.gade (Top 7 by date)
sanjayv.gade
18-Jul-12 5:39am
View
Even it prompts for login, i entered valid credentials but it fails and give unauthenticated users.
Login prompt window contains following warning message:
Warning: This server is requesting that your username and password be sent in an insecure manner (basic authentication without a secure connection).
It is for Basic authentication but i configured my application with windows authentication.
It was asking windows authentication login screen two days before and it was working fine.
Problem started from yesterday after restoring database.
sanjayv.gade
2-Apr-12 7:33am
View
Actually i want a status of jobs from task scheduler through application. for that i have used dll it has a function which retrives job status. application hosted on windows server 2008-R2, on this server we want some rights so we need to do impersonation.
You are right, Only service or admin account can impersonate other users. and i have service/admin account, when i provide admin details into the web config file it works fine. but it is not working same with coding(VB.Net)
below is code i have tried:
Public Function StartImpersonation(ByVal sUserName As String, ByVal sDomain As String, ByVal sPassword As String) As Boolean
Dim bResults As Boolean = False Dim sErrorMessage As String
Dim oWindowsIdentity As WindowsIdentity
Dim hPrimaryToken As IntPtr = IntPtr.Zero 'a Win32 handle to our authentication token
Dim hImpersonationToken As IntPtr = IntPtr.Zero 'a Win32 handle to our impersonation token
If sUserName = String.Empty Then
Throw New ArgumentException("UserName may not be NULL or String.Empty")
End If 'If no domain is given, assume the account is a local one
If sDomain = String.Empty Then
sDomain = Environment.MachineName End If Try
'Validate the provided userid, password and domain.
If LogonUserA(sUserName, sDomain, sPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hPrimaryToken) <> 0 Then
'Convert our token to one whos handle has TOKEN_IMPERSONATE set
If DuplicateToken(hPrimaryToken, SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, hImpersonationToken) <> 0 Then
'Create a new identity object based on our impersonation token
oWindowsIdentity = New WindowsIdentity(hImpersonationToken)
'Switch to our new identity
m_oImpersonationContext = oWindowsIdentity.Impersonate()
If Not (m_oImpersonationContext Is Nothing) Then
m_bImpersonationActive = True
bResults = True End If
Else
sErrorMessage = String.Format("DuplicateToken failed (rc={0})", Runtime.InteropServices.Marshal.GetLastWin32Error)
'Throw New Security.Authentication.AuthenticationException(sErrorMessage)
End If Else
sErrorMessage = String.Format("LogonUser failed (rc={0})", Runtime.InteropServices.Marshal.GetLastWin32Error)
'Throw New Security.Authentication.AuthenticationException(sErrorMessage)
End If Finally
If Not hImpersonationToken.Equals(IntPtr.Zero) Then
CloseHandle(hImpersonationToken)
hImpersonationToken = IntPtr.Zero End If
If Not hPrimaryToken.Equals(IntPtr.Zero) Then
CloseHandle(hPrimaryToken)
hPrimaryToken = IntPtr.Zero End If End Try
Return bResults End Function
sanjayv.gade
2-Apr-12 7:27am
View
Actually i want a status of jobs from task scheduler through application.
for that i have used dll it has a function which retrives job status. application hosted on windows server 2008-R2, on this server we want some rights so we need to do impersonation. but i am not calling any exe file, then Is it right to create new proccess thread for that?
sanjayv.gade
29-Mar-12 3:48am
View
please check this code which i've added
<authentication mode="Windows">
<identity password="password" username="domainname\username" impersonate="True">
<authorization>
<allow users="*"> <!-- Allow all users -->
sanjayv.gade
21-Nov-11 4:32am
View
thanx dude.....
sanjayv.gade
10-Nov-11 5:36am
View
thank a lot
sanjayv.gade
9-Nov-11 9:27am
View
actually i want to get Result of perticular job, is it fail or successfully run?
Show More