swinomish Posted July 11, 2008 Posted July 11, 2008 I am looking for a little help regarding syntax using variables in an LDAP statement.Here is a piece of my code that works perfectly'This section adds the new user to the Department Security GroupSet objGroup = GetObject ("LDAP:// cn=Bingo,OU=NLC Departments,dc=nlc,dc=com") Set objUser = GetObject("LDAP:// cn=John Public,OU=NLC Users,dc=nlc,dc=com")objGroup.add(objUser.ADsPath)I have two variables that are captured in my form .. strDepartment & strUser that I am having problems inserting into the above LDAP statement in the CN field. The strDepartment Variable can be chosen from a drop down list that reads from my AD. There can be 12 choices, I used CN=Bingo as a test example, any of the other 11 work as well.When I try it like this I get object not found on server.. I have used the & symbol and Quotes “” in various spots but cannot seen to find the correct syntax. any ideas? 'This section adds the user to the Department Security GroupSet objGroup = GetObject ("LDAP:// cn=strDepartment,OU=NLC Departments,dc=nlc,dc=com") Set objUser = GetObject("LDAP:// cn=strUser,OU=NLC Users,dc=nlc,dc=com")objGroup.add(objUser.ADsPath)ThanksSam
CoffeeFiend Posted July 11, 2008 Posted July 11, 2008 You can't just use variable names in the middle of a string. You have to close the string, add your variable, then add the last part (each part must be properly enclosed in quotes).Set objGroup = GetObject ("LDAP://cn=" & strDepartment & ",OU=NLC Departments,dc=nlc,dc=com") Set objUser = GetObject("LDAP://cn=" & strUser & ",OU=NLC Users,dc=nlc,dc=com")objGroup.add(objUser.ADsPath)
swinomish Posted July 11, 2008 Author Posted July 11, 2008 You can't just use variable names in the middle of a string. You have to close the string, add your variable, then add the last part (each part must be properly enclosed in quotes).Set objGroup = GetObject ("LDAP://cn=" & strDepartment & ",OU=NLC Departments,dc=nlc,dc=com") Set objUser = GetObject("LDAP://cn=" & strUser & ",OU=NLC Users,dc=nlc,dc=com")objGroup.add(objUser.ADsPath)Thanks , it works perfectly now... I don't know why I did not see that before.. just looking at it to long I guess
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now