Prev: IIS6 with basic authentication
Next: same problem
From: Praveen DM on 9 Sep 2010 07:02 Hi Lyon - I am Praveen from india..I was looking for an information to get complete redirect list from our server and could get only your script on net , But I am not aware how to execute your script given on net. We are administrating servers that are 7 - 8 years old and there are many redirects set in this course of time and nothing is accounted, I need a script which could fetch the redirected URLa nd if possible other information related to the redirected virtual folder etc... Can you please assist me with a VBscript or the script that you have posted on net ..( A working ) and how to execute to get results. Your reply will be of a great help for me. Thank You ! D.M.Praveen > On Tuesday, November 04, 2008 11:14 AM lyndon.hill wrote: > Hi, > > I'm attempting to obtain a list of all virtual directories that have the > HttpRedirect property set, allong with the redirect target. It seems that I > ought to be using WMI and so i have the following; > > public ArrayList ListWebSiteRedirects(string sSitename) > { > ArrayList tmpList = new ArrayList(); > string sQuery = ""; > if(sSitename == "") > { > sQuery = "SELECT * FROM IIsWebVirtualDirSetting"; > } > else > { > sQuery = "SELECT * FROM IIsWebVirtualDirSetting WHERE Name > LIKE '" + sSitename + "%'"; > } > try > { > ManagementObjectSearcher searcher = new > ManagementObjectSearcher(_scope, new ObjectQuery(sQuery), null); > ManagementObjectCollection websites = searcher.Get(); > foreach (ManagementObject web in websites) > { > string s = getPropertyValue(web); > if(s != "") > { > string sTemp = > web.Properties["Name"].Value.ToString(); > int i = sTemp.LastIndexOf('/'); > string sSite = sTemp.Substring(i); > tmpList.Add(sSite + " = " + s); > } > } > } > catch (Exception ex) > { > string s = ex.Message; > return tmpList; > } > return tmpList; > } > > public string getPropertyValue(ManagementObject site) > { > string sReturn = ""; > string[] sTemp; > try > { > sTemp = > site.Properties["HttpRedirect"].Value.ToString().Split(','); > sReturn = sTemp[0]; > } > catch (Exception ex) > { > sReturn = ex.Message; > } > return sReturn; > } > > This works, however it is extremely slow. We have hundreds of 'sites' set up > purely as redirects for search optimisation, and this code is running on a > machine on a different network to the IIS server. > > I realise that I'm raising loads of exceptions in getPropertyValue(), my > first attempt was to loop through all the properties looking for > HttpRedirect, which also worked and was no faster. > > My question(s) are then; > > Is this the right approach in the first place? > > Can I get this information faster or more efficiently by extending the query > to add another Where clause? Something like; > > sQuery = "SELECT * FROM IIsWebVirtualDirSetting WHERE Name LIKE '" + > sSitename + "%' and website.property = 'HttpRedirect'"; > > The desired result is present all existing redirects, perhaps in a grid, > allowing the user to add new ones or delete existing ones. At present this is > a Windows Forms app, running on a remote machine. Possibly it might be an > asp,.net app, running on the IIS box. I would think this might be faster, but > presents definite impersonation/authorisation issues. Also the IIS server is > actually a web farm so I need to replicate any changes amongst the physical > servers but that's for another day... > > Any insight would be very welcome. > > Lyndon Hills >> On Wednesday, November 05, 2008 4:23 AM wjzhan wrote: >> Hi Lyndon, >> >> Sure, you can make the query like: >> >> "SELECT * FROM IIsWebVirtualDirSetting WHERE Name LIKE '" + sSitename + "%' >> and HttpRedirect != ''" >> >> Then you can directly extract the HttpRedirect property from every >> IIsWebVirtualDirSetting object from the query result other than process all >> IIsWebVirtualDirSetting objects in a for-each(should be thousands of >> virtual directory elements since you have hundreds of sites). I think the >> change will make performance significantly better. >> >> Furthermore some redirections may not be set on virtual directories but on >> common web directories or site roots. So you may also query the >> HttpRedirect property of IIsWebDirectorySetting object to get the entire >> results. >> >> Please feel free to let me know if you have any further question. >> >> Have a good day. >> >> Sincerely, >> >> WenJun Zhang >> >> Microsoft Online Community Support >> >> Delighting our customers is our #1 priority. We welcome your comments and >> suggestions about how we can improve the support we provide to you. Please >> feel free to let my manager know what you think of the level of service >> provided. You can send feedback directly to my manager at: >> msdnmg(a)microsoft.com. >> >> ================================================== >> Get notification to my posts through email? Please refer to >> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications. >> >> MSDN Managed Newsgroup support offering is for non-urgent issues where an >> initial response from the community or a Microsoft Support Engineer within >> 2 business day is acceptable. Please note that each follow up response may >> take approximately 2 business days as the support professional working with >> you may need further investigation to reach the most efficient resolution. >> The offering is not appropriate for situations that require urgent, >> real-time or phone-based interactions. Issues of this nature are best >> handled working with a dedicated Microsoft Support Engineer by contacting >> Microsoft Customer Support Services (CSS) at >> http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx >> ================================================== >> This posting is provided "AS IS" with no warranties, and confers no rights. >>> On Friday, November 07, 2008 2:14 AM wjzhan wrote: >>> You are welcome Lyndon. Let me know if there is any further problem. >>> >>> Sincerely, >>> >>> WenJun Zhang >>> >>> Microsoft Online Community Support >>> >>> Delighting our customers is our #1 priority. We welcome your comments and >>> suggestions about how we can improve the support we provide to you. Please >>> feel free to let my manager know what you think of the level of service >>> provided. You can send feedback directly to my manager at: >>> msdnmg(a)microsoft.com. >>> >>> ================================================== >>> Get notification to my posts through email? Please refer to >>> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications. >>> >>> MSDN Managed Newsgroup support offering is for non-urgent issues where an >>> initial response from the community or a Microsoft Support Engineer within >>> 2 business day is acceptable. Please note that each follow up response may >>> take approximately 2 business days as the support professional working with >>> you may need further investigation to reach the most efficient resolution. >>> The offering is not appropriate for situations that require urgent, >>> real-time or phone-based interactions. Issues of this nature are best >>> handled working with a dedicated Microsoft Support Engineer by contacting >>> Microsoft Customer Support Services (CSS) at >>> http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx >>> ================================================== >>> This posting is provided "AS IS" with no warranties, and confers no rights. >>>> On Saturday, November 08, 2008 3:05 AM teneg wrote: >>>> On 5 Nov, 09:23, wjzh...(a)online.microsoft.com ("WenJun Zhang[msft]") >>>> wrote: >>>> Hi WenJun, >>>> >>>> Many thanks for that, it is very helpful. >>>> >>>> Lyndon >>>> Submitted via EggHeadCafe - Software Developer Portal of Choice >>>> Scrolling in WPF Toolkit?s Column Chart >>>> http://www.eggheadcafe.com/tutorials/aspnet/0939d60c-8e17-4a27-b898-1fc772d2d6f6/scrolling-in-wpf-toolkits-column-chart.aspx
|
Pages: 1 Prev: IIS6 with basic authentication Next: same problem |