Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get root of the directory data tree on a directory server
- DirectoryEntry dirEntry = new DirectoryEntry("LDAP://rootDSE");
- // get the hostname of the directory server of your root (I'm assuming that's what you want)
- string dnsHostname = dirEntry.Properties["dnsHostname"].Value.ToString();
- IPAddress[] ipAddresses = Dns.GetHostAddresses(dnsHostname);
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Net;
- using System.Net.Sockets;
- using System.DirectoryServices.AccountManagement;
- using System.DirectoryServices.ActiveDirectory;
- public doIt()
- {
- DirectoryContext mycontext = new=DirectoryContext(DirectoryContextType.Domain,"project.local");
- DomainController dc = DomainController.FindOne(mycontext);
- IPAddress DCIPAdress = IPAddress.Parse(dc.IPAddress);
- }
Add Comment
Please, Sign In to add comment