Page 1 of 1

How to write vbscrip to connect AD

Posted: Mon May 16, 2011 4:55 pm
by QuangNgo
Hi guys

I'm working on project that need to connect to Active Directory to check whether user is existed or not ?
I used to use Vb.Net and C#.net to AD , but in livecode just run vbscript to connect AD , so is it Vb.net and VBscript is similar.
Could I use Vb.net to connect to AD ? if so , what should I do ?
Hope you guys give me some solution to fix that problem
Thanks a lot
Quang

Re: How to write vbscrip to connect AD

Posted: Fri May 20, 2011 10:49 am
by QuangNgo
Hi guys

I had a vbscript to check whether user exist or not on AD,and now it work well when I run vbscript file.
But in livecode how to pass parameter to this vbscript. On my way is :
put cd field "Authentication" of cd "Test" of stack "Untitled 1" into tVB
put field "Users" into tFullUserID
put field "Passs" into tPassword
replace "strUsername" with "'"&tFullUserID&"'" in tVB-- strUsername is in vbscript
replace "strPassword" with "'"&tPassword&"'" in tVB-- same

and in that vbscript I return value after authentication with AD
but It just return "Execute error"
hope you guy give me ideas to pass parameter into vbscript

Re: How to write vbscrip to connect AD

Posted: Fri May 20, 2011 12:14 pm
by Klaus
Hi Quang,

did you check the resulting complete VB scripts?
Put it into a field and I am sure you will SEE where the problems are! :D

Quick hint:
User parenthesis to construct your strings:
...
replace "strUsername" with ("'"&tFullUserID&"'") in tVB
replace "strPassword" with ("'"&tPassword&"'") in tVB
...

To avoid possible problems (e.g. with "wrong" Quotes) you should put the quotes
directly in the field with the "template" VB script. Know what I mean?

In your example I would put this into the template VB script:
...
... 'strUsername' ...
... 'strPassword' ...
...

Then you will only need to replace the "naked" strings:
...
replace "strUsername" with tFullUserID in tVB
replace "strPassword" with tPassword in tVB
## The single QUOTES will remain untouched!
...


Best

Klaus

Re: How to write vbscrip to connect AD

Posted: Mon May 23, 2011 4:12 pm
by QuangNgo
Thanks Klaus
Sorry to reply late , but I'm very happy with your explain and my job's done :D
You and SparkOut gave to me 2 option and Those are very useful
Thanks a lot for both you guys

Quang :D