|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB 2005 with Active DirectoryHow can I enumerate AD objects (only in a given OU, not sub OUs) using the
DirectoryEntry object? Let me know of this is the wrong forum for this question. Thanks, Iain Hi Lain,
Based on my understanding, you want to enumerate the sub objects under certain OU. Then, can you be specific about which objects you want to enumerate? I think the key point is binding to the correct LDAP string(which you can get the detailed LDAP string with tool such as ADSI Edit), and then you can enumerate its sub properties. For example, if you want to enumerate the users in a group, you may refer to the sample listed in the link below: "Enumerating Users in a Group" http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/enu merating_users_in_a_group.asp The article below provided a more complex sample about enumerate AD objects in .Net: "Enumerating Active Directory Objects using C#" http://www.codeproject.com/dotnet/adtester.asp You also will find a lot of code samples regarding using System.DirectoryServices in sub-nodes of the link below: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/usi ng_system_directoryservices.asp If you need specific help or I have misunderstood you, please feel free to tell me, thanks. Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. I'm unexperienced in C, but I'll have a look at
http://www.codeproject.com/dotnet/adtester.asp. I got sample code to use the DirectorySearch object, but that returns all objects in AD, not just the OU I'm interested in. I'm basically wanting to write my own version of the AD Users & Computers mmc console. Thanks for the reply, Iain The sample code on the Microsoft website ""Jeffrey Tan[MSFT]"" wrote: Show quoteHide quote > Hi Lain, > > Based on my understanding, you want to enumerate the sub objects under > certain OU. > > Then, can you be specific about which objects you want to enumerate? I > think the key point is binding to the correct LDAP string(which you can get > the detailed LDAP string with tool such as ADSI Edit), and then you can > enumerate its sub properties. For example, if you want to enumerate the > users in a group, you may refer to the sample listed in the link below: > "Enumerating Users in a Group" > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/enu > merating_users_in_a_group.asp > > The article below provided a more complex sample about enumerate AD objects > in .Net: > "Enumerating Active Directory Objects using C#" > http://www.codeproject.com/dotnet/adtester.asp > > You also will find a lot of code samples regarding using > System.DirectoryServices in sub-nodes of the link below: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/usi > ng_system_directoryservices.asp > > If you need specific help or I have misunderstood you, please feel free to > tell me, thanks. > > Best regards, > Jeffrey Tan > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. > > Hi Lain,
Thanks for your feedback! Do you mean that you are not familiar with C#? Oh, yes, it is strange that most of the samples I find are written in C#, not VB.net. However, the basic idea is the same. I found one VB.net sample of accessing the user list, for your information: "Accessing LDAP User list using VB.NET" http://www.codeproject.com/vb/net/LDAP_Using_VBnet.asp The best way to translate the C# sample code into VB.net is using Reflector. *Reflector* is a tool written by Microsoft engineer Lutz Roeder. It uses .Net Reflection to parse the internal information of the .Net FCL assemblies. It also decomplies the MSIL code in the FCL into various languages, such as C#, VB.net, IL etc... It is somewhat like ILdasm.exe in .Net Framework, but provides higher level language(C#) display. Using it, you can see the source code of .Net FCL. It is a must have tool for .Net developer. You may download it for free in the link below: http://www.aisto.com/roeder/dotnet/ In your scenario, you can use Reflector to open the assemblies generated by these C# samples. Then you can switch the language from C# to VB.net, then you can view the sample code in VB.net. Besides Reflector, you may also some C# to VB.net translators to convert the sample code. However, these convertion tools are not perfect, you have to correct the translated VB.net code, I normally use the one below: http://authors.aspalliance.com/aldotnet/examples/translate.aspx Additionally, since you want to write your own version of the AD Users & Computers mmc console, I found a lot more samples in .Net doing the similar task, you may refer to their source code as sample: "Simple Active Directory Browser" http://www.codeproject.com/dotnet/activedirectorybrowser1.asp "Dynamically browse Active Directory Objects" http://www.codeproject.com/dotnet/Active_Directory_Browser.asp "Querying Active Directory using .NET classes and LDAP queries" http://www.codeproject.com/dotnet/activedirquery.asp Finally, since the .Net DirectoryService encapsulates Win32 ADSI technology, I am sure you will get more useful and professional help in the microsoft.public.adsi.general newsgroup. There are several ADSI programming experts(MVP) in this newsgroup, and some of them even authored 1 or 2 AD books. :-) Hope this helps. Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. That's a lot of helpful information you've passed on! I'll look at the URL's
you provided; they look as if they can give me a good start. Thanks a lot for your help! Iain |
|||||||||||||||||||||||