Wednesday, May 20, 2009
How to deny users in ASP.NET application to some path.
If you need to deny all the users except admin group to some location you could add next
< location path ="Admin" >
<system.web>
<authorization >
<allow roles = "Admin" />
<deny users = "*" />
</authorization >
</system.web>
</ location>
If you need to grant anonymous access to Extras/Services folder on some Forms or Windows based authorizated application
< location path ="Extras/Service" >
<system.web>
<authorization >
<allow users = "*" />
</authorization >
</system.web>
</ location>
Useful Tf Command-Line Utility Commands
You can navigate the console here: Start / All Programs / Microsoft Visual Studio 2008 / Visual Studio Tools / Visual Studio 2008 x64 Win64 Command Prompt
Visual Studio 2005 and 2008
If you have both versions of VS installed, you need to add the TFS server to 'Team Explorer' on both of them, otherwise you would not be able to work with VS2005 projects from VS2008 console and vice versa. Also I recommend to use the same server aliace name on both of them. It would help you to avoid the situations when you have to add '/server:AnotherServerAliace' parameter while accessing VS2005 projects from VS2008 console and vice versa.
Common error: TF30076: The server name
Working with project's environment
Here I demonstrate you 3 commands which you need to run under the project's root directory.
Watch who has uncommited and checkouted files for the project AxCMS_Sample
C:\Projects\AxCMS_Sample> tf status . /recursive /user:*
Get list of all the commities for user Bogdanov in AxCMS_Sample project
C:\Projects\AxCMS_Sample>tf history . /recursive /user:Bogdanov
Do 'get latest' for the project AxCMS_Sample
C:\Projects\AxCMS_Xtopia>tf get . /recursive
Working with workspaces
It is very often needed to install the solution to other (tester's or designer's) computer and it is very necessary not to mix workspaces otherwise when you logoff after successful installation - no one should be able to work with that solution (in VS2005/2008) on that machine - only you. Because solution is being associated with current machine and user who installed it. This information is named as "workspace" and stored into TFS server and will not allow anybody except you to work with that solution on that machine.
Common error: The working folder 'C:\Projects' already in use by the workspace 'MITCHELL;AXINOM\krolov' on computer 'MITCHELL'. Where MITCHELL is computer name and AXINOM\krolov or krolov is user.
Get the list of workspaces for user Bogdanov on all the computers
tf workspaces /owner:bogdanov
Open the workspace for editing
tf workspace lessing;bogdanov
Delete the unneeded workspace
tf workspace /delete ogawa;bogdanov
More about Tf Command-Line Utility Commands:
http://msdn.microsoft.com/en-us/library/z51z7zy0(VS.80).aspx
Tuesday, May 19, 2009
How to avoid IISREST from using on servers
In short, iisreset is bad. Running it on production servers is especially bad. Restarting or stopping IIS, or rebooting your Web server, is a severe action. When you restart the Internet service, all sessions connected to your Web server (including Internet, FTP, SMTP, and NNTP) are dropped. Any data held in Web applications is lost. All Internet sites are unavailable until Internet services are restarted. For this reason, you should avoid restarting, stopping, or rebooting your server if at all possible.
Known problems on Exchange Servers after IISRESET
Running IISRESET on Exchange Server will not affect to start back SMTP, POP3, MS Exchange Routine Engine services.
How to restart approporiate Web Site
You can restart the site in IIS manager or by editing web.config file under site's root directory - open it in notepad, add a space, remove the space, and save. The change to the file timestamp will cause the site to reload. In both cases workin process (application pool) will continue working.
How to restart approporiate Application Pool
Each Application Pool is completely separated from other App Pools by running in its own process called w3wp.exe (in IIS5 aspnet_wp.exe). Only problem if server has multiple sites under each application pool on staging and production servers. It could be done because it keeps the overheads to be minimal (each W3WP.exe process needs circa 25MB to run). But of course it increases the vulnerability even whether ASP.NET hosting server has medium trust level, because it allows to write data everywhere under the same Application Pool. But this is another threat.
IIS6
First of all you need to identify which application pool is associated with which w3wp.exe process. Open CMD, navigate system32 directory and type:
C:\Windows\System32> cscript iisapp.vbs
You will get a table like
W3WP.exe PID: 788 AppPoolId: N24
W3WP.exe PID: 4836 AppPoolId: Irbi
W3WP.exe PID: 2668 AppPoolId: BV
W3WP.exe PID: 2200 AppPoolId: Heise
W3WP.exe PID: 1716 AppPoolId: Roedl
Now you need to kill approporiate process. It will start again automatically after the next web site request. So run:
C:\Windows\System32> taskkill /PID 788
IIS7
Here steps are more easilly done. Get the needed name of the approporiate Application Pool in the IIS manager. Go to %windir%\system32\inetsrv and recycle an application pool by running
C:\Windows\System32\inetsrv> appcmd recycle apppool "apppool_name"
How to disalbe IISRESET from the command line
At a command prompt, type iisreset /disable, and press ENTER. This command disables IIS and prevents all iisreset calls from executing.
More links:
Restarting IIS (IIS 6.0)
What does iisreset do in IIS 7.0?
How to reset a session on remote server
W2K3 and W2K8 based systems allow only 2 administrators to be remotly connected to them. Sometimes could happen that someone forgot to logoff or your own session has broken and you are unable to log off by logoff button.
Fortunately there is an easy solution. Windows 2000+ (includes Windows XP, 2003 and 2008) have two command-line tools called qwinsta and rwinsta that can query and reset a remote session. Also for resetting sessions you able to use reset tool.
COMMANDS & SYNTAX
qwinsta - list local sessions
qwinsta /server:servername - list sessions on 'servername'
qwinsta /server:servername /counter - list sessions on 'servername' & provide connection counts
rwinsta sessionnid /server:servername - ends session 'sessionnid' on server 'servername'
reset session sessionid /server:servername - ends session 'sessionnid' on server 'servername'
For example:
>qwinsta /server:white
SESSIONNAME USERNAME ID STATE TYPE
console 0 Conn wdcon
rdp-tcp 65536 Listen rdpwd
rdp-tcp#41 lints 1 Active rdpwd
rdp-tcp#45 bogdanov 2 Active rdpwd
>reset session 2 /server:white
or
>rwinsta 2 /server:white