directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pepe_gaetano <pepe_gaet...@live.it>
Subject Re: LDAP Error:The directory service is not available
Date Wed, 28 Oct 2009 13:02:48 GMT

Hi
thanks a lot ... it works
I ask you a question? and if I want to add a group what should I use? no
"inetOrgPerson" but what?



Stefan Seelmann-3 wrote:
> 
> Hi,
> 
> pepe_gaetano wrote:
>> Hi
>> 
>> I have a problem with LDAP, I use apache directory server and I would add
>> a
>> new user ....I use Visual Studio and the code 
>> 
>> is:
>> 
>> public static void prova(string FullName)
>>         {          
>>             DirectoryEntry container;
>>             DirectoryEntries ChildEntry;
>> 
>>             container = new
>> DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system",
>> "admin", "secret");
> 
> Is "cn=user1, ou=users,ou=system" really your container or do you want
> to add new entries to "ou=users,ou=system"?
> 
> To do a simple bind you need to use a bind DN and specify the right
> authentication type (AuthenticationTypes.None). I'm not sure if other
> authentication types work with non-AD servers.
> 
>>             try
>>             {
>> 
>>                 ChildEntry = container.Children;
>>                 DirectoryEntry NewEntry = ChildEntry.Add("cn=" +
>> FullName,
>> "user");
> 
> Apache Directory Server doesn't contain the "user" object class. So if
> you haven't added it to the schema you should use another object class
> (e.g. inetOrgPerson)
> 
> Before you commit the changes you need to add all the other mandatory
> attributes (cn and sn for inetOrgPerson).
> 
>>                 NewEntry.CommitChanges();
>>                 NewEntry.Close();
>>             }
>>             catch (Exception ex)
>>             {
>>                 throw new Exception("Error " + ex.Message);
>>             }
>>          }
> 
> Here is your modified code that works for me:
> 
> try
> {
>     DirectoryEntry Container = new DirectoryEntry(
>         "LDAP://192.168.2.101:10389/ou=users,ou=system",
>         "uid=admin,ou=system", "secret", AuthenticationTypes.None);
> 
>     DirectoryEntries ChildEntries = Container.Children;
>     DirectoryEntry NewEntry = ChildEntries.Add(
>         "cn=" + FullName, "inetOrgPerson");
>     NewEntry.Properties["cn"].Add(FullName);
>     NewEntry.Properties["sn"].Add(FullName);
> 
>     NewEntry.CommitChanges();
>     NewEntry.Close();
> }
> catch (Exception ex)
> {
>     Console.Out.WriteLine(ex.Message);
>     Console.Out.WriteLine(ex.StackTrace);
> }
> 
> 
> BTW: There is a much better C# LDAP API from Novell, see [1][2]. There
> are also many examples available.
> 
> 
> Kind Regards,
> Stefan
> 
> 
> [1] http://forge.novell.com/modules/xfcontent/downloads.php/ldapcsharp
> [2] http://www.novell.com/coolsolutions/feature/11204.html
> 
> 

-- 
View this message in context: http://www.nabble.com/LDAP-Error%3AThe-directory-service-is-not-available-tp26057800p26094259.html
Sent from the Apache Directory Project mailing list archive at Nabble.com.


Mime
View raw message