Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem with ADSI script

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem with ADSI script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Problem with ADSI script - 7/15/2008 6:50:12 AM   
  brandonrjackson

 

Posts: 2
Score: 0
Joined: 7/15/2008
Status: offline
I have a (hopefully) very basic question.  I am trying to utilize the ADS_NAME_INITTYPE_GC lookup to query our Global Catalog Server and do a ADS Name Translation.  However, I get error code -2147463160 (0x80005008) on the line.  Everything is written (as near as I can tell) exactly like it states on the MSDN site,  but I cannot get it to work (and since it won't initialize, I cannot set or translate the name).  Here is the code snippet:

Set adsNameTranslate = CreateObject("NameTranslate")
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, ""

adsNameTranslate.Set ADS_NAME_TYPE_DOMAIN_SIMPLE, username2
userDN = adsNameTranslate.Get (ADS_NAME_TYPE_1779)

 
The "username2" variable (defined earlier in the script) is username@domain.com.  I want to translate that into the full DN of the user.  The error code says that I have an ADS_BAD_PARAMETER, but I cannot figure out what is wrong (it is a very basic call).  Any help would be appreciated.  Thanks!

For reference (to show this is not a complicated script), the entire script is below (actual domain name has been changed to domain.com).  I am creating a script that will prompt the user to enter a username, and then have it translate to the DN and disable the account.

dim username
dim datestamp
dim userDN
dim username2

 
username= InputBox( "Enter Username to be disabled")
datestamp= InputBox( "Enter datestamp to be added to Description field")



username2 = username & "@domain.com"
 
' Use NameTranslate (ADSI) to translate SAM account name to Display Name
Set adsNameTranslate = CreateObject("NameTranslate")
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, ""

adsNameTranslate.Set ADS_NAME_TYPE_DOMAIN_SIMPLE, username2
userDN = adsNameTranslate.Get (ADS_NAME_TYPE_1779)


'Disable Account
Set ou = GetObject("LDAP://OU=Test,DC=domain,DC=com")
Set ObjUser = GetObject ("LDAP://" & userDN)
objUser.AccountDisabled = True
objUser.SetInfo

Wscript.echo "Account is now disabled"
wscript.quit
 
 
Post #: 1
 
 RE: Problem with ADSI script - 7/15/2008 12:22:05 PM   
  dm_4ever


Posts: 2666
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Are you defining the constants?

Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_INITTYPE_SERVER = 2
Const ADS_NAME_INITTYPE_GC = 3

Const ADS_NAME_TYPE_1779= 1
Const ADS_NAME_TYPE_CANONICAL = 2
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_DISPLAY = 4
Const ADS_NAME_TYPE_DOMAIN_SIMPLE = 5
Const ADS_NAME_TYPE_ENTERPRISE_SIMPLE = 6
Const ADS_NAME_TYPE_GUID= 7
Const ADS_NAME_TYPE_UNKNOWN = 8
Const ADS_NAME_TYPE_USER_PRINCIPAL_NAME = 9
Const ADS_NAME_TYPE_CANONICAL_EX= 10
Const ADS_NAME_TYPE_SERVICE_PRINCIPAL_NAME= 11
Const ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME = 12 

< Message edited by dm_4ever -- 7/15/2008 12:27:52 PM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to brandonrjackson)
 
 
Post #: 2
 
 RE: Problem with ADSI script - 7/16/2008 12:06:50 AM   
  brandonrjackson

 

Posts: 2
Score: 0
Joined: 7/15/2008
Status: offline
That was it....  (did I mention I am new at this).

Thanks so much for the help.  I appreciate it!

Brandon

(in reply to dm_4ever)
 
 
Post #: 3
 
 
 
  

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 >> Problem with ADSI script Page: [1]
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