"RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
news:1a553212-5780-4c56-91f4-6e88fc6fd4e2@xxxxxx
On Aug 16, 3:18 pm, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
> Richard,
>
> To add on to my first reply.
>
> My domain name is cph.local
>
> I'm Trying to pull my security groups out of the following OU (we'll
> name the first one testGroup) - Security Groups \ File Access Groups
>
> What would the query would look like (just so I can get my variable
> assigned similar to how you have the following set up in your
> logon4.txt file) -- Set objGroup1 = GetObject("LDAP://
> cn=TestGroup,ou=Sales,dc=MyDomain,dc=com")
>
> Thanks - again the help is much appriciated in advance.
>
> Boyle
> --------------
> If your domain is cph.local, and the Common Name of the group is
> "TestGroup", and it resides in an ou called "ou=File Access Groups", which
> in turn resides in "ou=Security Groups" (which is at the root of the
> domain), then you would bind with:
>
> Set objGroup1 = GetObject("LDAP://cn=TestGroup,ou=File Access
> groups,ou=Security Groups,dc=cph,dc=local")
>
> The binding string (the string in quotes above) can be difficult to
> determine if you are not used to the syntax. It reflects the hierarchy of
> your AD domain. You can use ADSI Edit to browse objects in AD and view the
> value of the distinguishedName attribute. Or, in ADUC, look at the "Fully
> qualified domain name of the object" on the "Object" tab. This lists the
> components in reverse order. For example, if the "Fully qualified domain
> name" is:
>
> cph.local/Security Groups/File Access Groups/TestGroup
>
> then your binding string will match my example above. The only thing is
> you
> cannot tell if the components are ou, dc, or cn from the fully qualified
> name.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> -- Richard,
Thanks again for the quick response ---
Here is what my logon script currently looks like:
Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"
Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
Set objGroup1 = GetObject("LDAP://cn=IT$ DEPARTMENT (R & W),ou=File
Access Groups,ou=Security Groups,dc=cph,dc=local")
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(objGroup1) Then
wshNetwork.RemoveNetworkDrive "I:"
wshNetwork.RemoveNetworkDrive "Z:"
wshNetwork.RemoveNetworkDrive "K:"
wshNetwork.MapNetworkDrive "I:", "\\netwincp\it$\"
wshNetwork.MapNetworkDrive "Z:", "\\netwincp\accounting\"
wshNetwork.MapNetworkDrive "K:", "\\netwincp\kdrive\"
End If
----------------
When I go to login into a box on my cph.local domain I'm getting the
following error message:
Line 16 / Char 1
Error - Wrong number of arguments or invalid property assignment:
'InStr'
Code - 800A01C2
MS VBScript error.
----
Any ideas on what this error message is comming from and how to fix
it.
Thanks again Richard, the help is much appriciated.
Ryan
-----------
You pass the object reference objGroup1 to the InStr function, which will
raise an error. You probably need something like:
If (InStr(strGroups, ENGINEERING_GROUP) > 0) Then
Using this technique, there is no need to bind to the group objects, since
you are comparing to the Common Names of the groups, using the constants you
defined. Unless you use the group object reference, don't bind since it
slows down the script.
There is one gotcha you need to look out for. The Join function will raise
an error unless the memberOf attribute of the user has at least two values.
It may have one or even no values. In place of:
strGroups = LCase(Join(CurrentUser.MemberOf))
I would use
=======
On Error Resume Next
arrGroups = CurrentUser.GetEx("memberOf")
If (Err.Number <> 0) Then
On Error GoTo 0
strGroups = ""
Else
On Error GoTo 0
strGroups = LCase(Join(arrGroups)
End If
=======
This is one of those commonly used methods (I think even suggested by
Microsoft), which is flawed. The GetEx method improves on the situation,
because it only raises an error if there are no groups. If there is one
group, it retrieves the attribute as an array with one value. You still must
trap the error if there are no groups. I explain this, and other issues, in
this link:
http://www.rlmueller.net/MemberOf.htm
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--