Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ADSI Active Directory - User Modification VB Errors - PutEx, GetInfoEx

Posted on 2004-09-07
9
Medium Priority
?
486 Views
Last Modified: 2013-12-25
I sincerely need some help with this one... I've been banging my head on the wall for ages...
I'm trying to modify the telephone numbers of a bunch of users in Active Directory whose Usernames I know... It connects to the user no problem... I can then access properties like "Full Name" without a problem...
BUT
When I try to access "TelephoneNumber" I receive "The Active Directory property cannot be found in the cache". So I did some research and you need to call getInfoEx to populate the variables... which I am now doing, but still get the same error.

Anyway, that aside, as I dont necessarily need to access the variable just set it... so I tried just using Put and PutEx to set the number and I receive "Automation Error" when calling both Put and PutEx.

I would really, really appreciate some help.

Here's the code which References the Active DS Type Library - c:\winnt\system32\activeds.tlb:
'--------------------------------------
Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4

Dim dso As IADsOpenDSObject
Dim container As IADsContainer
Dim tmpUser As IADsUser
Set dso = GetObject("WinNT:")
Set tmpUser = dso.OpenDSObject("WinNT://AD/jamesb", "Administrator", "password", 1)

tmpUser.GetInfoEx Array("telephonenumber"), 0
MsgBox tmpUser.Get("telephonenumber")
tmpUser.PutEx ADS_PROPERTY_UPDATE, "telephoneNumber", "0123456789"
tmpUser.SetInfo
'--------------------------------------

0
Comment
Question by:jamesbreen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11996618
0
 

Author Comment

by:jamesbreen
ID: 11996760
cheers mladenovicz, but this is what I have been going from!
According to the articles on that site my code should work.

0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11996834
I am not quite sure, but maybe property name is case sensitive

tmpUser.GetInfoEx Array("telephonenumber"), 0

tmpUser.PutEx ADS_PROPERTY_UPDATE, "telephoneNumber", "0123456789"

so try to change this to

tmpUser.PutEx ADS_PROPERTY_UPDATE, "telephonenumber", "0123456789"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jamesbreen
ID: 11996908
unfortunately not... just tried it.
sorry
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11996939
Try

tmpUser.PutEx ADS_PROPERTY_UPDATE, "telephoneNumber", Array("0123456789")
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11996956
or maybe, you should append that property to the collection:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iads_putex.asp
0
 

Author Comment

by:jamesbreen
ID: 11997030
afraid not... the array change didnt work...
and the value I am updating is a single value... you only append when its a multivalue field I think.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12279846
PAQed, with points refunded (125)

Computer101
E-E Admin
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question