Author: k_abhinav | Posted on: 12/28/2009 11:45:32 PM | Views : 554

I have to identify account used in IIS for anonymous access programmatically. This is for the purpose of registering the user with IIS using: regiis -ga <username>
I did below for that:
//Getting the list of users DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",Computer"); DirectoryEntries mem = localMachine.Children; //Get a user a/c with anonymous access to Internet Information Services foreach (DirectoryEntry dir in mem) { if (dir.SchemaClassName == "User" && dir.Properties["Description"].Value.ToString(). Equals("Built-in account for anonymous access to Internet Information Services")) { return dir.Name; } } return string.Empty; ...

Go to the complete details ...