c# ubuntu system.directoryServices pointing to novel active directory rather than windows AD.

Hi,
I have developed c# application using monodevelop/xamarin, which basically does ldap authentication with windows active directory. And This works fine in windows environment. but if i use the same code in the ubuntu, instead of authenticating to windows active directory, i think it is trying to authenticate with novell active directory. and fails with novell.ldap.exception invalid credentials. i have removed all the references to novell.directory.ldap, but system.directoryServices internally referring to novell assembly. So is there any way we can make it to refer to windows AD rather than novell AD?

My requirement is to basically authenticate with windows Active directory from ubuntu application. Is there any mono wrapper around System.DirectoryServices to achieve this, please suggest.

this is the piece of code always failing in ubuntu at Findall with invalid credentials. because it is always pointing to novell active directory

    string strLdapURL = "LDAP://" + Domain + ":389";
    DirectoryEntry entry = new DirectoryEntry(strLdapURL, strUserName, Password);
    DirectorySearcher mySearcher = new DirectorySearcher(entry);
    mySearcher.Filter = "(&(ObjectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=2)(operatingSystem=*server*))";
    mySearcher.PropertiesToLoad.Add("PwdLastSet");
    mySearcher.SizeLimit = int.MaxValue;
    mySearcher.PageSize = int.MaxValue;
    mySearcher.Tombstone = false;
    mySearcher.SearchScope = System.DirectoryServices.SearchScope.Subtree;
    System.DirectoryServices.SearchResultCollection entry1 = mySearcher.FindAll();

Thank you.

Posts

  • Just fixed it myself

    My assumption was wrong that novell.directory.ldap was pointing novell's active directory structure. this works with windows active directory also, its just matter of specifying proper windows active directory URL.
    I just added reference to novell.directory.ldap assembly, and then in the credentials changed username administrator to Administrator(case sensitive).
    and earlier i was just using username in the binding operation, there i appended domain name also like domain\Administrator. and i was able to get it working.

    here is the code snapshot for your reference.

            string strDomain = "domain";
            string strUserName = "Administrator";
            string Password = "Password123";
            String loginDN =  strDomain + "\\" + strUserName;
            int LdapVersion  = LdapConnection.Ldap_V3;;
            String ldapHost = domain;
    
    
            string strLdapURL = "LDAP://" + Domain + ":389";
             LdapConnection lc = new LdapConnection();
             lc.Connect( ldapHost, LdapPort );
         lc.Bind( LdapVersion, loginDN, password );
    
  • GurnamSharmaGurnamSharma INUniversity

    I am also facing same issue. Can you please show some code.

  • roshan.sulladroshan.sullad USMember

    whatever posted above that piece of code was having problem for me.
    remove any other windows active directory assembly references and keep only novel's assembly and before trying any changes in the code. first use ldap tool to test the active directory connection, it will help to identify the right syntax to use for authentication and then use that syntax in the code.

  • jiyongjiyong KRMember

    I am also facing same issue.

    lc.Connect( ldapHost, LdapPort ); --> Time out Error

    Searching for the second week.

    please let me know.

    This is my email address.

    [email protected]

    please......................

  • DotNetDevDotNetDev INMember ✭✭

    I am also facing same issue. Can you please show some code.

Sign In or Register to comment.