I am querying an LDAP server with a simple select and storing the result set in hidden variables. I then pass those hidden variables to another page, replace and apostrophes in the data and then split the data into arrays so that they will insert into a database. A sample of some of the code is listed below. This is what gets passed on the second page. ie FullNameDesc, EmailDesc, ManagerDesc and AliasDesc have a replace function on them to include double quotes for any words that have apostrophes.
Code:
strFullName = Split(FullNameDesc,", ")
strEmailName = Split(EmailDesc,", ")
strManagerName = Split(ManagerDesc,", ")
strAliasName = Split(AliasDesc,", ")
Now the Manager name is what I am currently working on and have issues. I am using a regex expression inorder to remove all the words/characters from the data except for the name. I have done this successfully with the following code.
Code:
set objRE = new RegExp
with objRE
..IgnoreCase = true
..Global = true
..pattern = "CN=(.*?),"
end with
set Names = objRE.execute(ManagerDesc)
Then I strip out the CN= and replace any apostrophes with double quotes so that they will insert correctly into a database as follows.
Code:
strName = Replace(Names, ("CN="), " ")
strName = Replace(Names, ",", " ")
strName = Replace(Names, "'", "''")
Then I perform my insert. However I am not sure how to add the regex value to the insert. Can anyone help construct the loop for the regex. If I exclude the variable(the manager variable/field) my insert will work. However, I am not how to insert the contents of the regex expression into my insert. This is the code I do have but receiving an error:
Code:
For i = 0 to Ubound(strFullName)
sSQL = "INSERT into Table (FullName, Email, Manager, Alias)"
sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i) &"', '" & strName(i) &"', '" & strAliasName(i) &"')"
'objConn2.Execute sSQL
NEXT
Code:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
/activedirectory/testpass.asp, line 65
I do not need to use the regex expression for any of my other variables except the managerName variable this is why you see only one instance of regex and not multiples.
Please could you telling me where I am going wrong, possibly modifying my code. Hopefully it can be done or else I will resort to removing the reg ex and insert the whole managername string into the database.
Thanks again.
Code:
strFullName = Split(FullNameDesc,", ")
strEmailName = Split(EmailDesc,", ")
strManagerName = Split(ManagerDesc,", ")
strAliasName = Split(AliasDesc,", ")
Now the Manager name is what I am currently working on and have issues. I am using a regex expression inorder to remove all the words/characters from the data except for the name. I have done this successfully with the following code.
Code:
set objRE = new RegExp
with objRE
..IgnoreCase = true
..Global = true
..pattern = "CN=(.*?),"
end with
set Names = objRE.execute(ManagerDesc)
Then I strip out the CN= and replace any apostrophes with double quotes so that they will insert correctly into a database as follows.
Code:
strName = Replace(Names, ("CN="), " ")
strName = Replace(Names, ",", " ")
strName = Replace(Names, "'", "''")
Then I perform my insert. However I am not sure how to add the regex value to the insert. Can anyone help construct the loop for the regex. If I exclude the variable(the manager variable/field) my insert will work. However, I am not how to insert the contents of the regex expression into my insert. This is the code I do have but receiving an error:
Code:
For i = 0 to Ubound(strFullName)
sSQL = "INSERT into Table (FullName, Email, Manager, Alias)"
sSQL = sSQL & "VALUES ('" & strFullName(i) &"', '"& strEmailName(i) &"', '" & strName(i) &"', '" & strAliasName(i) &"')"
'objConn2.Execute sSQL
NEXT
Code:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment
/activedirectory/testpass.asp, line 65
I do not need to use the regex expression for any of my other variables except the managerName variable this is why you see only one instance of regex and not multiples.
Please could you telling me where I am going wrong, possibly modifying my code. Hopefully it can be done or else I will resort to removing the reg ex and insert the whole managername string into the database.
Thanks again.