473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get current domain components for LDAP query?

Seth Schrock
2,965 Expert 2GB
I've got a function that gets a list of all the users in a specified Active Directory group via an LDAP query. Part of the query string is the domain components. For example, if my domain is Test.com, then the part of the query string in question would be
Expand|Select|Wrap|Line Numbers
  1. "<LDAP://DC=Test,DC=com>"
I would like to automate this so that I don't have to hard code these components. I have found an API that gets the "Test" portion (link), but I can't find anything for the ".com" portion.
Jul 29 '15 #1

✓ answered by Rabbit

Expand|Select|Wrap|Line Numbers
  1. Set objRoot = GetObject("LDAP://RootDSE")
  2. strDomain = objRoot.Get("DefaultNamingContext")

4 2565
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Set objRoot = GetObject("LDAP://RootDSE")
  2. strDomain = objRoot.Get("DefaultNamingContext")
Jul 29 '15 #2
Seth Schrock
2,965 Expert 2GB
Awsome! That is exactly what I was looking for. Thanks Rabbit!
Jul 29 '15 #3
Rabbit
12,516 Expert Mod 8TB
No problem!
Jul 29 '15 #4
NeoPa
32,556 Expert Mod 16PB
I use the following, which was recommended as the basic standard. Unfortunately, I have no idea where it came from originally.
Expand|Select|Wrap|Line Numbers
  1.         strDN = "LDAP://OU=MyBusiness," & _
  2.                 GetObject("LDAP://RootDSE").Get("rootDomainNamingContext")
It can't hurt to have multiple approaches to choose from.
Jul 30 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kmart | last post by:
Hi all I've been looking around google and the net searching for a way to sort the result of an LDAP-query without any luck. Is it possible to do this or do I have to make my own sorting routine...
2
by: Robert Bryan via .NET 247 | last post by:
Hello, Is there any way to determine which server answers an LDAP query? One that is not directed at a particular server that is. ie. DirectoryEntry oUser=new...
1
by: dln | last post by:
Hello all. I'm trying to find the right group to post this to and since it's a coding question (of sorts), hopefully this is the right place. I'm attempting to run an LDAP query to return the...
1
by: Dave | last post by:
Could someone fix this for me please. The last bit i cant figure out is the last line in the sub. Results.SetDataBinding(myTable.DefaultView, "") Thanks Dave ...
3
by: maria.s | last post by:
Hi, I've got a problem with an LDAP query submitted from my ASP.NET application. Configuration: Windows 2003 Server Standard Ed., the application uses Windows Integrated Authentication and is...
2
by: HamishC | last post by:
Hi all, I have been knocking my head against this one for a few days -- haven't been able to find a solution to this anywhere so hopefully someone can help. Situation: A really simple LDAP that...
7
by: MrHelpMe | last post by:
Sorry everyone, NOTE: I have posted this question to another site but unfortunately, am not getting the answers I need only because those helping haven't worked with ASP. I am in desperate...
1
by: tvnaidu | last post by:
any software to download certificates automatically for domain control / LDAP / OCSP? (for authentication purpose)
1
by: fatmitch | last post by:
Hi, I have just installed a 2003 DC to our 2000 Domain and the only problem i'm getting is from our intranet server, the ASP script which authenticates users with AD is getting the following error...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.