-
July 22nd, 2010, 11:43 PM
#1
How to get user data from VB Script?
Hi,
I am having 2 AD.
While running my script I will be providing userid to one of the AD and getting the required user data. Then using all that data, I will be creating new user in other AD.
If I run my script from same AD itself then it is working fine but when I am running it from some another machine in different domain then it is problem. It's giving error as "access denied".
To check the access I shared one folder on AD and tried accessing it from command prompt. That folder was accessible.
Below is part of my script which is giving problem
Code:
strNTName = "abcd"
strDNSDomain = "DC=AD,DC=COM"
' Use ADO to search Active Directory.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Properties("User ID") = "abcd"
adoConnection.Properties("Password") = "abcd_wxyz"
'adoConnection.Properties("Encrypt Password") = TRUE
'adoConnection.Properties("ADSI Flag") = 3
'adoConnection.Open
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire domain.
strBase = "<LDAP://" & strDNSDomain & ">"
' Search for all users.
strFilter = "(&(objectCategory=person)(objectClass=user)(samAccountName=" & strNTName & "))"
' Comma delimited list of attribute values to retrieve.
'strAttributes = "givenName,sn,mail,userPrincipalName"
strAttributes = "givenName,sn"
' Construct the LDAP query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
' Run the query.
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
MsgBox adoRecordset.RecordCount
Can anyone please help to solve this problem?
Thanks in advance.
Last edited by HanneSThEGreaT; July 23rd, 2010 at 01:19 AM.
Reason: Added [CODE] tags.
-
July 23rd, 2010, 01:19 AM
#2
Re: How to get user data from VB Script?
swap811, please use [CODE] tags when posting code.
-
July 23rd, 2010, 01:31 AM
#3
Re: How to get user data from VB Script?
Download ScriptoMatic for Active Directory. It will write scripts in a few languages, based on combo boxes. ScriptoMatic 2.0 is for non AD networks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|