![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | how to get a OU full address from AD I want get a full AD OU (e.g. computer) addess, how to do |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to get a OU full address from AD On Jul 24, 4:05 pm, how to get a OU full address from AD <how to get a OU full address from A...@xxxxxx> wrote: Quote: > I want get a full AD OU (e.g. computer) addess, how to do may help get you started.. Set objADSystemInfo = CreateObject("ADSystemInfo") x = inputbox(objADSystemInfo.UserName,objADSystemInfo.UserName ,objADSystemInfo.UserName) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to get a OU full address from AD "OfficeGuyGoesWild" <marty.lindsay@xxxxxx> wrote in message news:cbb09358-ca64-4ff8-84db-4d67c90223a7@xxxxxx Quote: > On Jul 24, 4:05 pm, how to get a OU full address from AD <how to get a > OU full address from A...@xxxxxx> wrote: Quote: >> I want get a full AD OU (e.g. computer) addess, how to do > This will give you the Distinguished name of the logged in user, which > may help get you started.. > > > Set objADSystemInfo = CreateObject("ADSystemInfo") > x = > inputbox(objADSystemInfo.UserName,objADSystemInfo.UserName > ,objADSystemInfo.UserName) ========= Option Explicit Dim objSysInfo, strComputerDN Set objSysInfo = CreateObject("ADSystemInfo") strComputerDN = objSysInfo.ComputerName Wscript.Echo strComputerDN ======== If all you have is the NetBIOS name of a computer, and you don't know where in the hierarchy of Active Directory the object resides, you can use the NameTranslate object. The Distinguished Name is the only attribute that indicates this and shows the OU. For example, the following VBScript program prompts for the NetBIOS name of a computer, determines the NetBIOS name of the domain, and converts to the Distinguished Name. The trick for computer objects is to realize that the sAMAccountName of the computer is the NetBIOS name with a trailing "$" appended. ========== Option Explicit Dim objRootDSE, strDNSDomain, objTrans, strNetBIOSDomain Dim strComputer, strComputerDN ' Constants for the NameTranslate object. Const ADS_NAME_INITTYPE_GC = 3 Const ADS_NAME_TYPE_NT4 = 3 Const ADS_NAME_TYPE_1779 = 1 ' Determine DNS name of domain from RootDSE. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") ' Use the NameTranslate object to find the NetBIOS domain name from the ' DNS domain name. Set objTrans = CreateObject("NameTranslate") objTrans.Init ADS_NAME_INITTYPE_GC, "" objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4) ' Remove trailing backslash. strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1) ' Prompt for the NetBIOS name of a computer. strComputer = InputBox("Enter NetBIOS name of a computer", "Find OU") ' Use the Set method to specify the NT format of the computer name. ' The sAMAccountName of the computer is the NetBIOS name with trailing "$". objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strComputer & "$" ' Use the Get method to retrieve the Distinguished Name. strComputerDN objTrans.Get(ADS_NAME_TYPE_1779) Wscript.Echo "Computer Distinguished Name" _ & vbCrLf & strComputerDN ========= For more information on the NameTranslate objects see this link: http://www.rlmueller.net/NameTranslateFAQ.htm -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Display of full email address | Vista mail | |||
| full address | Vista file management | |||
| Full path in the Address bar of Explorer??? | Vista installation & setup | |||
| full email address as username | Vista mail | |||
| Can I copy full paths from the address bar | Vista file management | |||