473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Finding a user in Active Directory

I have a program that I have created (VB.NET 2003) that takes anexcel spread sheet and creates a user based on what is in theSS. This is working properly. Now, I want the be able to takeanother spreadsheet and update information of the users in thatsheet. Here is my code on how I initially create the user:

Dim myDirectoryEntry As DirectoryServices.DirectoryEntry
Dim myDE As DirectoryServices.DirectoryEntry
Dim myEntries As DirectoryServices.DirectoryEntries

RootDSE = RootDSE.Insert(7, mOU)

myDE = New DirectoryServices.DirectoryEntry(RootDSE)
myEntries = myDE.Children
myDirectoryEntry = myEntries.Add("CN=" & mUserName, "user")
myDirectoryEntry.Properties("samAccountName").Valu e = mUserName

... Do other properties here

myDirectoryEntry.CommitChanges()

Now, when I run the second spread sheet it looks to see if theusername already exists and if it does then it checks to see ifthe first and last names match. If they match then they aresupposed to update the rest of the fields. So assuming I have acomplete match, this is the code that I do:

'Same as others above
myDirectoryEntry = myEntries.Find("CN=" & mUserName)

I get an error that say that the object is not found on theserver. I know that it is there... I can not figure out thecorrect syntax for the life of me... help!

BTW this program is running on a W2K domain controller.

Thanks

--------------------------------
From: Brian Denning

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>5RohlFfWuE6FY90ku5tt0g==</Id>
Nov 22 '05 #1
1 1414
>Now, I want the be able to take another spreadsheet and update information of the users in that sheet.

Okay, how about using the WHOLE user's LDAP path for that?? E.g. since
you *KNOW* where you created *WHICH* user, you should be able to fill
in the full user LDAP path name, no? Something like "cn=John
Doe,dc=YourCompany,dc=com".

Then use that LDAP path (or distinguished Name = DN) for the user, and
just bind to the user - no need to do a .Find or other search
operation!
myDirectoryEntry = new DirectoryEntry("LDAP://" + <value from spreadsheet>);


THen do your stuff to the user entry, and commit changes. Done!

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mike | last post by:
Greetings, I am writing an Intranet application in ASP.NET using VB.NET. I am obtaining the username of the user with: uName = User.Identity.Name, which is in the form of DOMAIN\username. I...
4
by: ASGMikeG | last post by:
Hi, How do I find the user object for the current user in Active Directory i.e. the user running my program ? Regards Michael
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
4
by: Mike | last post by:
Greetings, I am writing an Intranet application in ASP.NET using VB.NET. I am obtaining the username of the user with: uName = User.Identity.Name, which is in the form of DOMAIN\username. I...
2
by: NathanC | last post by:
'*********************************************** Dim MySearcher As New DirectorySearcher("LDAP://CN=Users,DC=corporate,DC=domainname,DC=com") ' Create a DirectorySearcher object. Dim resEnt As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.