public override LDAPObject GetDomain(LDAPSupportSettings settings) { try { string password = GetPassword(settings.PasswordBytes); var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); List <LDAPObject> searchResult = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_BASE, settings.StartTls, searchFilter, settings.UserDN); if (searchResult.Count == 0) { string domainDn = GetPossibleDomainDn(settings.Server); searchResult = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_BASE, settings.StartTls, searchFilter, domainDn); if (searchResult.Count == 0) { return(null); } } return(searchResult[0]); } catch (Exception e) { log.WarnFormat("Can't get current domain. May be current user has not needed permissions. {0}", e); return(null); } }
public override LDAPObject GetUserBySid(LDAPSupportSettings settings, string sid) { string password = GetPassword(settings.PasswordBytes); try { string ldapUniqueIdAttribute = ConfigurationManager.AppSettings["ldap.unique.id"]; List <LDAPObject> list; var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); if (ldapUniqueIdAttribute == null) { list = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(Constants.RFCLDAPAttributes.EntryUUID, sid)), settings.UserFilter, settings.UserDN); if (list == null || list.Count == 0) { list = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(Constants.RFCLDAPAttributes.NSUniqueId, sid)), settings.UserFilter, settings.UserDN); if (list == null || list.Count == 0) { list = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(Constants.RFCLDAPAttributes.GUID, sid)), settings.UserFilter, settings.UserDN); if (list == null || list.Count == 0) { list = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(Constants.ADSchemaAttributes.ObjectSid, sid)), settings.UserFilter, settings.UserDN); } } } } else { list = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(ldapUniqueIdAttribute, sid)), settings.UserFilter, settings.UserDN); } if (list.Count != 0) { return(list[0]); } } catch (Exception e) { log.ErrorFormat("Can not access to directory: {0}. {1}", settings.UserDN, e); } return(null); }
public override void CheckCredentials(string login, string password, string server, int portNumber, bool startTls) { var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); novellLdapSearcher.Search(login, password, server, portNumber, LdapConnection.SCOPE_BASE, startTls); }
public override List <LDAPObject> GetUsersByAttributesAndFilter(LDAPSupportSettings settings, string filter) { var password = GetPassword(settings.PasswordBytes); if (!string.IsNullOrEmpty(settings.UserFilter) && !settings.UserFilter.StartsWith("(") && !settings.UserFilter.EndsWith(")")) { settings.UserFilter = "(" + settings.UserFilter + ")"; } filter = "(&" + settings.UserFilter + filter + ")"; try { var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); return(novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, null, filter, settings.UserDN)); } catch (Exception e) { Log.ErrorFormat("Can not access to directory: {0}. {1}", settings.UserDN, e); } return(null); }
public override List <LDAPObject> GetUsersByAttributes(LDAPSupportSettings settings) { string password = GetPassword(settings.PasswordBytes); var criteria = Criteria.All(Expression.Exists(settings.LoginAttribute)); var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); List <LDAPObject> searchResult = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, criteria, settings.UserFilter, settings.UserDN); return(searchResult); }
public override bool CheckUserDN(string userDN, string server, int portNumber, bool authentication, string login, string password, bool startTls) { string[] attributes = { Constants.ADSchemaAttributes.ObjectClass }; var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); List <LDAPObject> searchResult = novellLdapSearcher.Search(login, password, server, portNumber, LdapConnection.SCOPE_BASE, startTls, searchFilter, userDN, attributes); if (searchResult.Count != 0) { return(true); } log.ErrorFormat("Wrong User DN parameter: {0}.", userDN); return(false); }
public override List <LDAPObject> GetGroupsByAttributes(LDAPSupportSettings settings) { try { string password = GetPassword(settings.PasswordBytes); var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); var groups = novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, null, settings.GroupFilter, settings.GroupDN); return(groups); } catch (Exception e) { log.ErrorFormat("Bad GroupDN or GroupName parameter. {0}", e); } return(null); }
public override List <LDAPObject> GetUsersFromPrimaryGroup(LDAPSupportSettings settings, string primaryGroupID) { var distinguishedName = settings.Server + ":" + settings.PortNumber + "/" + settings.UserDN; string password = GetPassword(settings.PasswordBytes); var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); try { return(novellLdapSearcher.Search(settings.Login, password, settings.Server, settings.PortNumber, LdapConnection.SCOPE_SUB, settings.StartTls, Criteria.All(Expression.Equal(Constants.ADSchemaAttributes.PrimaryGroupID, primaryGroupID)), settings.UserFilter, distinguishedName)); } catch (Exception e) { log.ErrorFormat("Can not access to directory: {0}. {1}", distinguishedName, e); } return(null); }
public override bool CheckGroupDN(string groupDN, string server, int portNumber, bool authentication, string login, string password, bool startTls) { string[] attributes = { Constants.ADSchemaAttributes.OBJECT_CLASS }; var novellLdapSearcher = new NovellLdapSearcher(AcceptCertificate); var searchResult = novellLdapSearcher.Search(login, password, server, portNumber, LdapConnection.SCOPE_BASE, startTls, SearchFilter, groupDN, attributes); if (searchResult.Count != 0) { return(true); } Log.ErrorFormat("Wrong Group DN parameter: {0}.", groupDN); return(false); }