I am trying to use the C# method shown here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/f55859db-6d44-46f3-ab25-751a23629f4a.asp in order to programatically add domains to an IIS 6 SMTP server. It worked in the past (ever heard THAT before?) but stopped working for reasons beyond my ken. I've tried adding user credentials for the adminsitrator to the DirectoryEntry creation, fiddled with IIS authentication all to no avail. Immediately on creating the "path" object shown below I can see it isn't connecting to the MetaBase. Letting the code run produces an "Unknown (0x80005000)" error. // Machine executing this code is WinXP SP2 // Machine targted by this code is Win2003 SP1 string result=""; string metabasePath = "IIS://a.server.local/SmtpSvc/1/Domain/existingdomain.com"; string newParentPath ="IIS://a.server.local/SmtpSvc/1/Domain/"; string newName = "newdomain.com"; try { DirectoryEntry path = new DirectoryEntry(metabasePath); // at this point Path.Bound = false DirectoryEntry newParent = new DirectoryEntry(newParentPath); if (path.Parent.SchemaClassName.ToString() == newParent.SchemaClassName.ToString()) { DirectoryEntry newPath = path.CopyTo(newParent, newName); newParent.CommitChanges(); result = "successfull copy from "+newParent.Path+" to "+newName; } else result = "Failed in CopyMetabaseNode; parent mismatch"; catch (Exception ex) { result = "Failed in CopyMetabaseNode with the following exception: "+ ex.Message; -- David L. West http://www.deskoptional.com
I'm not sure what the error here is as I don't really use the IIS provider, but you should be aware that you cannot supply credentials when using the IIS provider. You have to be running under the security context of an admin on the box you are trying to modify. Joe K. "David L. West" wrote in message news:op.szdnoycaz54syx@clea.dna.local... >I am trying to use the C# method shown here: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/f55859db-6d44-46f3-ab25-751a23629f4a.asp > > in order to programatically add domains to an IIS 6 SMTP server. It worked > in the past (ever heard THAT before?) but stopped working for reasons > beyond my ken. I've tried adding user credentials for the adminsitrator > to the DirectoryEntry creation, fiddled with IIS authentication all to no > avail. > > Immediately on creating the "path" object shown below I can see it isn't > connecting to the MetaBase. Letting the code run produces an "Unknown > (0x80005000)" error. > > // Machine executing this code is WinXP SP2 > // Machine targted by this code is Win2003 SP1 > > string result=""; > string metabasePath = > "IIS://a.server.local/SmtpSvc/1/Domain/existingdomain.com"; string > newParentPath ="IIS://a.server.local/SmtpSvc/1/Domain/"; > string newName = "newdomain.com"; > try > { > DirectoryEntry path = new DirectoryEntry(metabasePath); > // at this point Path.Bound = false > DirectoryEntry newParent = new DirectoryEntry(newParentPath); if > (path.Parent.SchemaClassName.ToString() == > newParent.SchemaClassName.ToString()) > { > DirectoryEntry newPath = path.CopyTo(newParent, newName); > newParent.CommitChanges(); > result = "successfull copy from "+newParent.Path+" to "+newName; > } > else > result = "Failed in CopyMetabaseNode; parent mismatch"; > catch (Exception ex) > { > result = "Failed in CopyMetabaseNode with the following exception: "+ > ex.Message; > > > -- > David L. West > http://www.deskoptional.com