views:

66

answers:

3

We have developed a ASP.NET 3.5 web application with Web Server 2008 and has implemented a custom authentication solution using active directory as the credentials store. Our front end application uses a normal login form to capture the user name and password and leverages the Win32 LogonUser method to authenticate the user’s credentials. When we are calling the LogonUser method, we are using the LOGON32_LOGON_NETWORK as the logon type.

The issue we have found is that user profile folders are being created under the C:\Users folder of the web server. The folder seems to be created when a new user who has never logged on before is logging in for the first time. As the number of new users logging into the application grows, disk space is shrinking due to the large number of new user folders getting created.

I need to get the token back after the authentication (authenticated \ password locked \ wrong password ) its futher use and based on logic showing different web pages

Has anyone seen this behavior with the Win32 LogonUser method?

Please answer the following issue:

Is it possible to disable this behavior to create the folder as taking 2.78 MB of space for every new user and it eating my disck space?

I have tried LOGON32_LOGON_BATCH but it was giving an error 1385 in authentication user. For any solution related to LOGON32_LOGON_BATCH, can you please confirm if that will stop creating the folders at location C:\users.

Also for any possible solution I need either

I am able to disable the folder to be created at C:\user or Any other option to authenticated user which will not creat folders.

+1  A: 

The MSDN documentation for LogonUser recommends LOGON32_LOGON_BATCH as the logon type for web services:

This logon type is intended for batch servers, where processes may be executing on behalf of a user without their direct intervention. This type is also for higher performance servers that process many plaintext authentication attempts at a time, such as mail or Web servers. The LogonUser function does not cache credentials for this logon type.

Have you tried that?

Gabe
I have tried LOGON32_LOGON_BATCH but its giving 1385 in authenticating the user.
Lalit_M
I have tried LOGON32_LOGON_BATCH but its giving error code 1385 in authenticating the user
Lalit_M
+1  A: 

Pass LOGON32_LOGON_BATCH and grant the users permission to log on as a batch job on that machine using Group Policy.

SLaks
The size of folder is around 2.87MB and it eating the disk space so this solution is not suitable for me. Can you suggest any other solution?
Lalit_M
The size of folder is around 2.87MB and it eating the disk space so this solution is not suitable for me. Can you suggest any other solution?
Lalit_M
This answer should solve your problem. Did you try it?
SLaks
A: 

You don't write any information about the version of products (.NET, Windows Server which you use) and the best answer on your question can depend on this. Moreover the best way for your solution depend on what you want to do with the users token after logon. Do you really want to use this token or you want only verify the user? So I try to answer most general on your question.

In general, error 1385 (ERROR_LOGON_TYPE_NOT_GRANTED) means following (see http://support.microsoft.com/kb/155012/en):

A user has requested a type of logon, such as interactive or network, that was not granted. An administrator has control over who may logon interactively and through the network.

There are SE_BATCH_LOGON_NAME and SE_DENY_BATCH_LOGON_NAME (NTSecAPI.h) privileges which can be disabled/enabled in your case (see http://msdn.microsoft.com/en-us/library/bb545671%28VS.85%29.aspx for description). Use Process Explorer started with administrator rights (see http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) to see which privileges has a process and which from there are enabled (see "Security" tab of a process). If your account used for the application pool don't have SE_BATCH_LOGON_NAME granted or this privilege is not enabled before call of LogonUser, you should add the corresponding code in your program.

By the way sometimes you don't really want to do much with an user account and want only verify a password. To do this you can use an old way with SSPI (see http://support.microsoft.com/kb/180548/en) which are used inside of LogonUser implementation. This way is the most smart and quick way to verify an user account which I know.

You can look at "The SSPI Workaround" (see http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToGetATokenForAUser.html) for more information of usage SSPI in .NET 2.0.

Oleg