Fascinating. It didn't used to work that way. It would actually bomb out on you with a COMException. Granted, I haven't looked at this in awhile, so I have no idea when they fixed it. It must have been fixed in the ADSI stack as this has nothing to do with .NET actually.
If you check the MSDN docs, they still actually list that limitation. The reason it was a limitation was pretty simple - they were using the underlying IADs object. Here is the code for .Parent for instance:
public DirectoryEntry Parent
{
get
{
this.Bind();
return new DirectoryEntry(this.adsObject.Parent, this.UsePropertyCache, this.GetUsername(), this.GetPassword(), this.AuthenticationType);
}
} Notice that they are using 'adsObject' here and calling the .Parent on it.
Now, refer to the
documentation and the relevant part:
When binding using the object GUID, some IADs and IADsContainer methods and properties are not supported. The following IADs properties are not supported by objects obtained by binding using the object GUID:
ADsPath
Name
Parent
The following IADsContainer methods are not supported by objects obtained by binding using the object GUID:
GetObject
Create
Delete
CopyHere
MoveHere
To use these methods and properties after binding to an object using the object GUID, use the IADs.Get method to retrieve the object distinguished name and then use the distinguished name to bind to the object again.I would be interested in knowing if the .Rename and .MoveTo functionality works now as well. This syntax used to not work with those (as documented).
Anyhow, good to know.
Ryan Dunn
Extemporaneous MumblingsThe .NET Developer's Guide to Directory Services Programming