You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by pepe_gaetano <pe...@live.it> on 2009/10/26 12:10:24 UTC

LDAP Error:The directory service is not available

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");

            try
            {

                ChildEntry = container.Children;
                DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName,
"user");
                NewEntry.CommitChanges();
                NewEntry.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Error " + ex.Message);
            }
         }

The problem is that I have this type of error:The directory service is not
available
somebody could help me?
-- 
View this message in context: http://www.nabble.com/LDAP-Error%3AThe-directory-service-is-not-available-tp26057800p26057800.html
Sent from the Apache Directory Project mailing list archive at Nabble.com.


Re: LDAP Error:The directory service is not available

Posted by pepe_gaetano <pe...@live.it>.
I tried with "uid = admin, ou = system" but I have always the same error
-- 
View this message in context: http://www.nabble.com/LDAP-Error%3AThe-directory-service-is-not-available-tp26057800p26058019.html
Sent from the Apache Directory Project mailing list archive at Nabble.com.


Re: LDAP Error:The directory service is not available

Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
Hi,

I believe you need to use the full DN of the user in your DirectoryEntry
creation.

Maybe the following code would work better...

DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system",

"uid=admin,ou=system", "secret");


Hope this helps,
Pierre-Arnaud

On Mon, Oct 26, 2009 at 12:10 PM, pepe_gaetano <pe...@live.it> 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");
>
>            try
>            {
>
>                ChildEntry = container.Children;
>                DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName,
> "user");
>                NewEntry.CommitChanges();
>                NewEntry.Close();
>            }
>            catch (Exception ex)
>            {
>                throw new Exception("Error " + ex.Message);
>            }
>         }
>
> The problem is that I have this type of error:The directory service is not
> available
> somebody could help me?
> --
> View this message in context:
> http://www.nabble.com/LDAP-Error%3AThe-directory-service-is-not-available-tp26057800p26057800.html
> Sent from the Apache Directory Project mailing list archive at Nabble.com.
>
>

Re: LDAP Error:The directory service is not available

Posted by Stefan Seelmann <se...@apache.org>.
Hi Pepe,

use groupOfNames or groupOfUniqueNames.

I'd kindly recommend to study some LDAP book first in order to learn the
LDAP basics. A nice online book is http://www.zytrax.com/books/ldap/

Kind Regards,
Stefan


pepe_gaetano wrote:
> 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
>>
>>
> 


Re: LDAP Error:The directory service is not available

Posted by pepe_gaetano <pe...@live.it>.
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.


Re: LDAP Error:The directory service is not available

Posted by Stefan Seelmann <se...@apache.org>.
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

Re: LDAP Error:The directory service is not available

Posted by pepe_gaetano <pe...@live.it>.
the server and port I think they work because I checked using Apache Studio!
the error is here 
newentry = ChildEntry.Add DirectoryEntry ( "cn =" + FullName, "user");

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


Re: LDAP Error:The directory service is not available

Posted by Stefan Seelmann <se...@apache.org>.
Hi,

And you are sure that ApacheDS runs on your machine on port 10389?

Could you try to get a more details error message?

Could you find out which line of your code causes the error?

A last advice is to use capture the network traffic, for example using
Wireshark (but afaik it is not possible to capture the localhost
interface on Windows).

Kind Regards,
Stefan


pepe_gaetano schrieb:
> 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");
> 
>             try
>             {
> 
>                 ChildEntry = container.Children;
>                 DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName,
> "user");
>                 NewEntry.CommitChanges();
>                 NewEntry.Close();
>             }
>             catch (Exception ex)
>             {
>                 throw new Exception("Error " + ex.Message);
>             }
>          }
> 
> The problem is that I have this type of error:The directory service is not
> available
> somebody could help me?