Hi,
I have problem getting all domains. My code looks like:
_dirEntry.Path = "LDAP://RootDSE"
_strRootDomain = "LDAP://" & _dirEntry.Properties("rootDomainNamingContext").Va lue.ToString()
_dirEntry.Path = _strRootDomain
_dirSearch.SearchRoot = _dirEntry
_dirSearch.Filter = "(objectClass=domainDNS)"
_resultColl = _dirSearch.FindAll
For Each _result As SearchResult In _resultColl
cmbDomains.Items.Add(_result.Properties("name").It em(0).ToString)
Next
I am not able to test, but I believe that this code returns all domains in LAN? Next problem I have is that I would like to add user from domain to SQL. My domain is like: comp-domain.com (LDAP://dc=comp-domain,dc=com), but when logging to domain I use COMP\username. Using Environment.UserDomainName returns the correct domain name "COMP", but I want to get values like this for all domains. Can anyone help?