Hi all,
I am new to System.DirectoryServices programming. I am trying few samples at home. But somehow the samples in MSDN uses Organizational unit and other AD terms and I dont knwo how to use them at home. I dont have any Active Directory setup in my machine. Moreover the System.DirectoryServices samples in MSDN doesn't work when I try them at home. Here is a basic task I wanted to do. I wanted to add a user to a group. When I use the DirectorySearcher component it throws an exception saying "Domain does not exist or could not be contacted" and sometimes "server not operational" and when I use the FindAll method it says "the provider doesnt allow searching" etc. and various other weird errors which Icouldn't make out. I am pasting a small code snippet. This is not a sample in MSDN. I tried it on my own. I know I must be wrong somewhere. Can anyone help me out Thanks
Here it is :
Let us say the Group Name is HRINFO and the user is
HR.
DirectoryEntry dom = new
DirectoryEntry("WinNT://Home", @"Home\Narayan", "");
foreach (DirectoryEntry de in
dom.Children)
{
if (de.SchemaClassName == "Group")
{
if (de.Name == grpName)
{
de.Children.Add(userName,
"user");
de.CommitChanges();
break;
}
}
}
When I run this code it does enumerate through the groups but when I reach the group that I want the user to be added I am not able to add the user as it throws an exception "WinNT://HomeNetwork/Home/HRINFO is not a container".
I didnt mention the name of my Wireless Netwrok SSID in the path but did it pick up "HomeNetwork" in the path. Home is the name of my machine running WinXP SP2 and I have a wiresless network at home whose SSID is "HomeNetwork".
Any help or suggestion is appreciated. Thanks a ton.
Regards
Narayan

System.DirectortServices
Henryk
Hi Joe,
Thanks a lot for the suggesstion. But I remember working with ADSI in VB6.0. You might know that we never had this ADAM at that time. We just use to create the objects in the local machine itself like users, groups, setting user properties etc. Any reason that it shouldn't work with ADAM. Please let me know. Thanks.
CoDavid
To play with DirectoryServices on your dev machine, the easiest thing is to install ADAM:
http://www.microsoft.com/downloads/details.aspx FamilyId=9688F8B9-1034-4EF6-A3E5-2A2A57B5C8E4&displaylang=en