- bits & pieces about software development HostingAbc Logo
Show all posts.
If you've ever wondered how could you list all your usernames and passwords that are set on the 'Directory Security' tab on each website's properties (in inetmgr) then this small C# code snippet would be for you ..
Just a note: so far it seems that this code snippet works only on Windows Server 2003 - i have no ideea why doesn't it work on XP / Vista as well (don't care actually :) - i needed it for win 2003)...

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
static void Main(string{} args)
{
    DirectoryEntry iisBase = new DirectoryEntry("IIS://localhost/W3SVC");
    PrintUserNameAndPass(iisBase);
}

private static void PrintUserNameAndPass(DirectoryEntry iisChild)
{
    String userName = null; 
    String password = null;
    
    if (iisChild.Properties{"AnonymousUserName"} != null)
    {
        userName = iisChild.Properties{"AnonymousUserName"}.Value as String;
    }
    if (iisChild.Properties{"AnonymousUserPass"} != null)
    {
        password = iisChild.Properties{"AnonymousUserPass"}.Value as String;
    }

    if (userName != null && password != null)
    {
        if (!userNames.Contains(userName))
        {
            byte{} passwordChars = ASCIIEncoding.ASCII.GetBytes(password);
            Console.WriteLine(String.Format("{0}\t{1}", userName, 
              System.Convert.ToBase64String(passwordChars)));
            userNames.Add(userName);
        }
    }

    foreach (DirectoryEntry newChild in iisChild.Children)
    {
        PrintUserNameAndPass(newChild);
    }

    iisChild.Dispose();
}


Update: Actually I've found out that the exception on Windows Vista was caused by the lack of IIS6 compatibility module. So I've just had to install this compatibility module from Windows features and everything works as expected.
add linkThe last comments:moszidev says:Venemo: it is at System.Web.Configuration.HttpConfigurationSystem.UseHttpConfigurationSystem moszidev says:dumb, ... no wonder your name is dumb :) ... i more or less expected these type of answers :) - trust me, i know the double locking design pattern :) ... but it seems that you don't really know for what the locking is needed ;) ...dumb says:this is called double locking: http://en.wikipedia.org/wiki/Double_checked_locking_patternVenemo says:Where did you find this in the framework?moszidev says:just found out that the maximum transfer rate on USB or UTP for this router is 3.5MBytes/sec. (that is 28MBit / sec)[br] So if you have a connection speed higher than this, it will not be fully used for sure.moszidev says:yepp, i know dd-wrt as well ;) - actually what i liked in oleg's firmware is that he didn't change the web ui ( which actualy i turned it off completely now ... ) - he just added new functionality to it.Kornel Javor says:If you're interested in custom firmwares, you should try dd-wrt too. As far as I know, your gadget is supported. Take a look at http://dd-wrt.com Dozens of new features were revealed after it was deployed to my Linksys and turned to a thousand do
Copyright (C) 2007, Molnar Szilveszter m@il me