Nov 23, 2007 #1 JPJeffery Technical User Joined May 26, 2006 Messages 600 Location GB Hi If I have the name of a group, how can I pull out the full AD/LDAP path? e.g. Code: DEPT_IT to Code: CN=DEPT_IT,CN=Users,DC=acme,DC=com JJ [small][purple]Variables won't. Constants aren't[/purple][/small]
Hi If I have the name of a group, how can I pull out the full AD/LDAP path? e.g. Code: DEPT_IT to Code: CN=DEPT_IT,CN=Users,DC=acme,DC=com JJ [small][purple]Variables won't. Constants aren't[/purple][/small]
Nov 23, 2007 1 #2 bslintx Technical User Joined Apr 19, 2004 Messages 425 Location US Code: Set oRoot = GetObject("LDAP://rootDSE") sDomainPath = oRoot.Get("defaultNamingContext") Set oConnection = CreateObject("ADODB.Connection") oConnection.Provider = "ADsDSOObject" oConnection.Open "Active Directory Provider" sGroup = "DEPT_IT" Set oRs = oConnection.Execute("SELECT adspath " & _ "FROM 'LDAP://" & sDomainPath & "'" & _ "WHERE objectCategory='group' AND " & _ "Name='" & sGroup & "'") If Not oRs.EOF Then sAdsPath = oRs("adspath") msgbox(sAdspath) Else msgbox("Not in AD") End If Upvote 0 Downvote
Code: Set oRoot = GetObject("LDAP://rootDSE") sDomainPath = oRoot.Get("defaultNamingContext") Set oConnection = CreateObject("ADODB.Connection") oConnection.Provider = "ADsDSOObject" oConnection.Open "Active Directory Provider" sGroup = "DEPT_IT" Set oRs = oConnection.Execute("SELECT adspath " & _ "FROM 'LDAP://" & sDomainPath & "'" & _ "WHERE objectCategory='group' AND " & _ "Name='" & sGroup & "'") If Not oRs.EOF Then sAdsPath = oRs("adspath") msgbox(sAdspath) Else msgbox("Not in AD") End If
Nov 23, 2007 Thread starter #3 JPJeffery Technical User Joined May 26, 2006 Messages 600 Location GB And that's so simple. Yet, well, maybe it's the search criteria I was using in Google because I couldn't find that info anywhere. Thank you, bslintx. Have a star (even though I've not tested it yet)! JJ [small][purple]Variables won't. Constants aren't[/purple][/small] Upvote 0 Downvote
And that's so simple. Yet, well, maybe it's the search criteria I was using in Google because I couldn't find that info anywhere. Thank you, bslintx. Have a star (even though I've not tested it yet)! JJ [small][purple]Variables won't. Constants aren't[/purple][/small]
Nov 24, 2007 #4 bslintx Technical User Joined Apr 19, 2004 Messages 425 Location US no problem jeff...i tested the code already on a development server and worked fine....here is a good link for you http://www.microsoft.com/technet/scriptcenter/scripts/ad/default.mspx?mfr=true Upvote 0 Downvote
no problem jeff...i tested the code already on a development server and worked fine....here is a good link for you http://www.microsoft.com/technet/scriptcenter/scripts/ad/default.mspx?mfr=true