Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Re: Table Does not Exist on searching user name in AD

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2430
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Re: Table Does not Exist on searching user name in AD
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 Re: Table Does not Exist on searching user name in AD - 4/13/2005 4:05:28 AM   
  weeden

 

Posts: 1
Score: 0
Joined: 4/13/2005
From:
Status: offline
I've had the same problem and came up with an alternative fix:

Instead of hard coding the username and password in the ASP page. Change the user account that the directory uses for anonymous access to run under an account that has access to Active Directory and BINGO!

(in reply to aek)
 
 
Post #: 21
 
 Re: Table Does not Exist on searching user name in AD - 4/13/2005 8:02:06 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I don't believe his problem lies with the credential though.

I guess he solved the problem already.

Cheers

(in reply to aek)
 
 
Post #: 22
 
 Re: Table Does not Exist on searching user name in AD - 4/14/2005 9:27:45 AM   
  abrarmuhib

 

Posts: 3
Score: 0
Joined: 4/14/2005
From: USA
Status: offline
Dear All,

Need your help and guidance.

I am using the following code snippet to check for the existence of a computer object in the active directory with the same name as the name of the computer on which my code is running.

The intention is to search the object and delete it ,if present and then add the current computer to the domain in a different OU.
Here is the code
-------------------------------------------------
on error resume next

Set WshNetwork = CreateObject("WScript.Network")
compName = WshNetwork.COMPUTERNAME
wscript.echo compName

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;UserID=user;Password=pwd;"
wscript.echo err.description

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = "<LDAP://OU=abc,OU=xyz,OU=pqr,DC=ghi,DC=mybank,DC=com>;(cn=" &_ compName & ");distinguishedName;subtree"

wscript.echo objCommand.CommandText

Set objRecordSet = objCommand.Execute
wscript.echo err.description & err.number
While Not objRecordset.EOF
strDN = objRecordset.Fields("distinguishedName")
objRecordSet.MoveNext
Wend
set objConnection = nothing
--------------------------------------------------------

This code snippet will indicate that the object exists or not and then i can take appropriate actions.

Issues ::
1. this code works beautifully if i run it on a computer which is already a part of that domain and when i have logged in as a domain user with appropriate rights.
2.If i run this code from the same computer by logging with a non domain id(local computer id), this code does not run. The error it gives is "Table does not exists". This happens even when i give the domain administrative id and password while making the ADODB connection in the code above.
3. This code also fails when the computer i am running it from is not in the domain altogether.

Guidance_ I need to know

1. Is it possible for a computer to query a domain controller when it is not in the domain.
2. If yes, what changes should i do in my code to achieve that.

Your help and guidance can save some hair. I have been snaching them to resolve this.

Thanks,

Abrar

(in reply to aek)
 
 
Post #: 23
 
 Re: Table Does not Exist on searching user name in AD - 4/14/2005 10:30:32 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
You said, "I am using the following code snippet to check for the existence of a computer object in the active directory with the same name as the name of the computer on which my code is running."

I dont' think it's possible to have a duplicated computer names exist anywhere in AD. Do you ever get 2 computers returned when running through the recordset ? I think your untimate goal is to determine whether there is a computer account in AD that has that same account name as the local computer from which the script is executing. If so, remove/re-create it.

Replace:

objCommand.CommandText = "<LDAP://OU=abc,OU=xyz,OU=pqr,DC=ghi,DC=mybank,DC=com>;(cn=" &_ compName & ");distinguishedName;subtree"

with:
objCommand.CommandText = "<LDAP://DC_NAME/OU=abc,OU=xyz,OU=pqr,DC=ghi,DC=mybank,DC=com>;(cn=" &_ compName & ");distinguishedName;subtree"

(in reply to aek)
 
 
Post #: 24
 
 Re: Table Does not Exist on searching user name in AD - 4/15/2005 3:12:45 AM   
  abrarmuhib

 

Posts: 3
Score: 0
Joined: 4/14/2005
From: USA
Status: offline
You captured my requirement precisely.

Pardon me for my ignorance but what does a dc name typically look like.

Do i have to give the name of the machine on which the domain controller is residing or do i have to simply give the string "ghi.mybank.com" as the Dcname.

Thanks for all the info.

Abrar

(in reply to aek)
 
 
Post #: 25
 
 Re: Table Does not Exist on searching user name in AD - 4/15/2005 4:26:10 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Either NetBIOS name or DQDN of the DC will do fine =)

I would just use the NetBIOS name since workgroup machines might not have full access to DNS and whatnot.

(in reply to aek)
 
 
Post #: 26
 
 Re: Table Does not Exist on searching user name in AD - 4/15/2005 6:26:41 AM   
  abrarmuhib

 

Posts: 3
Score: 0
Joined: 4/14/2005
From: USA
Status: offline
I used the dcname as ghi.mybank.com and the code worked fine.

I am able to query the active directory succesfully.

I am facing a new problem now....

I am trying to delete this queried object using the following code

----------------------------------------------------
on error resume next

DistinguishedName = "cn=abrar,OU=abc,OU=def,DC=ghi,DC=mybank,DC=com"
Set objLdap = GetObject("LDAP:")
wscript.echo "LDAP Creation :: " & err.description & err.number

Set objWks = objLdap.OpenDSObject_
("ldap://ghi.mybank.com" & DistinguishedName , "userid", "pwd", 1)

wscript.echo "Locating computer object:: " & err.description

set returnCode = objWks.DeleteObject(0)

wscript.echo "Deleting computer object :: " & err.description

-----------------------------------------------------------------

This code is erroring out at creation of objWks i.e the function opendsobject is failing with the return code 2147467259 and description is unspecified error.

I am running this code from a computer which is not part of the domain from which i am trying to delete this object.

I have tried removing ghi.mybank.com from the ldap statement in opendsobject but even then i get the same error code and description.


HELP NEEDED PLEASE!!!!!

(in reply to aek)
 
 
Post #: 27
 
 Re: Table Does not Exist on searching user name in AD - 4/15/2005 9:01:35 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Set objWks = objLdap.OpenDSObject("ldap://ghi.mybank.com/" & DistinguishedName,"userid","pwd",1)

You missed the "/" after the FQDN DC name.

(in reply to aek)
 
 
Post #: 28
 
 
Page:  <<   < prev  1 [2]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Re: Table Does not Exist on searching user name in AD Page: <<   < prev  1 [2]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts