473,395 Members | 1,730 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,395 software developers and data experts.

Creating/Updating Users in Active Directory

Hi,

I'm currently writing a Windows Service that takes user information
from an oracle Database and creates/updates users in an Active
Directory. My problem is that my app eventually runs out of memory.
Basically I'm doing this

DirectoryEntry Base = new
DirectoryEntry("LDAP://path/ou",user,password);
foreach(DataRow row in ds.Tables[0].Rows)
{
mySearcher.Filter = "((sAMAccountName="+row["primaryKey"]+"))";
try
{
if(mySearcher.FindAll().Count==0) //User not found
{
DirectoryEntry NewUser = Base.Children.Add("CN="+row[primaryKey],
"User");
foreach(staticattributes xyz in configObj.staticMappingArray)
{
NewUser.Properties[xyz.ldapAttribute].Value=xyz.staticValue;
}
foreach(mapping xyz in configObj.dataMappingArray)
{
if(row[xyz.dbField].ToString()!="")
{
NewUser.Properties[xyz.ldapAttribute].Value=row[xyz.dbField];
}
}
try
{
NewUser.Properties["displayName"].Value=NewUser.Properties["givenName"].Value+"
"+NewUser.Properties["sn"].Value;
NewUser.CommitChanges();
}
catch(Exception exc)
{
Console.WriteLine(row[0].ToString() + " Invalid Record");
}
}
else //User exists in LDAP
{
}
}
catch(Exception exce)
{
Console.WriteLine(row[0].ToString() + " Invalid Key");
}
}

The memory ramps up on each "if(mySearcher.FindAll().Count==0)" and
doesn't release the memory.

How can I run the app, but make sure it efficiently releases memory so
that the tasks can finish.

Thanks
Nov 16 '05 #1
1 1273
>I'm currently writing a Windows Service that takes user information
from an oracle Database and creates/updates users in an Active
Directory. My problem is that my app eventually runs out of memory.

The memory ramps up on each "if(mySearcher.FindAll().Count==0)" and
doesn't release the memory.


There is a known memory bug in .FindOne(), which can cause trouble. It
should be fixed in the Whidbey release (coming up in mid 2005), or you
can alternatively use .FindAll() instead of .FindOne() (there's no
leak in .FindAll() ).

Marc

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

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

Similar topics

0
by: Wayne Gibson | last post by:
Hi all, Please ignore the other post.. The cat jumped on the machine and sent it before I could stop it!! Was wondering if anybody has expericence this problem.. I am writting an application...
1
by: elziko | last post by:
Hi, I'm using the following code to create a user: Dim strNodeName As String = "test user" Dim NewUser As DirectoryEntry Dim AD As New DirectoryEntry("WinNT://MYCOMPUTER") 'delete user...
1
by: B. Zuidgeest | last post by:
I use C# to connect a database with student information directly to the Active Directory (2003). This means that as the student is enlisted an account and mailbox is created in the active...
7
by: Jaydeep | last post by:
Hi, Anybody knows how to create virtual directory programmatically under root directory ofcourse from code-behind. I am developing web-based application where I need to create a folder and making...
5
by: J'son | last post by:
<REPOSTED> Guys, I need to build a web intranet application that can automatically create a user account when a new user registers on the site. The user account will be on the web server,...
3
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
6
by: Mr Newbie | last post by:
Hi, Im in a situation where I need to restrict users, but I dont have access or wont be allowed access to manage groups in the domain. How can I restrict access is this case ? -- Best...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.