0
votes

I have not worked with Active Directory before and I need to make a connection between Unity standalone implementation in C# and Active Directory installed on a Windows Server 2012 R2 via LDAP. Every time I connect, I get the same error:

LdapException: (49) Invalid Credentials LdapException: Server Message: 8009030C: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 2030, v2580

And I am sure that my username and password are correct.

DirectoryEntry entry = new DirectoryEntry("LDAP://"+ serverName+":"+port,userName,password);

    DirectorySearcher ds = new DirectorySearcher(entry);

    ds.Filter = "XX";

    SearchResult result = ds.FindOne();
    ResultPropertyCollection rpc = result.Properties;
    foreach (string property in rpc.PropertyNames)
    {
        foreach (object value in rpc[property])
            console.text+="Property = " + property + "Value = " + value;
    }
}
catch (Exception ex)
{
    Debug.Log(ex);
}

I already tried with LdapAdmin (open-source LDAP directory management tool) but I received the same error even with ldp command line in windows PowerShell. Any help will be appreciated. Screenshot

1
Can you show your code? - Gabriel Luci
What is the format of the username in userName? Is it domain\username or [email protected]? (please edit your question rather than adding an answer) - Gabriel Luci
I tried both but with the same error, can you check the screenshot that I recently added ? Thank you for your time. - Wajdi Mnasri
See the answer below. There must be a typo in your username. It's not lying to you :) - Gabriel Luci

1 Answers

2
votes

It's obscure, but the reason you got denied is in the error message. The real error is the value of the data field. In this case, the error is 0x2030.

Convert the value to decimal to get 8240.

Then do a lookup of the error. The FormatMessage API will give you that, or on the command line, you would do:

net helpmsg 8240

And you would get

There is no such object on the server.

That means the username you are using does not exists, has a typo, etc.