Last post Jun 26, 2009 05:34 PM by StevenSw
Member
460 Points
279 Posts
Jun 13, 2009 10:47 PM|StevenSw|LINK
Sumply return the path of AD when executed on a domain.
public string ActiveDirectoryPath() { DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE"); using (root) { string dnc = root.Properties["defaultNamingContext"][0].ToString(); string server = root.Properties["dnsHostName"][0].ToString(); string adsPath = String.Format("LDAP://{0}/{1}", server, dnc); return adsPath; } }
20 Points
10 Posts
Jun 25, 2009 03:29 PM|wildquaker|LINK
In a using code block eh? Is an object with a DirectoryEntry type disposable?
Jun 26, 2009 05:34 PM|StevenSw|LINK
See: http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry_members(VS.80).aspx and http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx
Member
460 Points
279 Posts
Snippet to obtain Active Directory Path
Jun 13, 2009 10:47 PM|StevenSw|LINK
Sumply return the path of AD when executed on a domain.
Radical Development
Dont forget to click "Mark as Answer" on the post that helped you.
Member
20 Points
10 Posts
Re: Snippet to obtain Active Directory Path
Jun 25, 2009 03:29 PM|wildquaker|LINK
In a using code block eh? Is an object with a DirectoryEntry type disposable?
Member
460 Points
279 Posts
Re: Snippet to obtain Active Directory Path
Jun 26, 2009 05:34 PM|StevenSw|LINK
See: http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry_members(VS.80).aspx and http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx
Radical Development
Dont forget to click "Mark as Answer" on the post that helped you.