public static ModifyRequestChange Extract(ICollection <byte> buffer) { var result = new ModifyRequestChange(); result.ExtractTagAndLength(buffer); result.Operation = DEREnumerated <ModifyRequestChangeOperations> .Extract(buffer); result.Modification = PartialAttribute.Extract(buffer); return(result); }
private void CheckSyntax(LDAPEntry entry, PartialAttribute attribute, string dn) { var syntax = entry.Attributes.FirstOrDefault(a => a.Name == _options.SyntaxAttributeName); if (syntax != null) { var attributeSyntax = _attributeSyntaxLst.FirstOrDefault(a => a.OID == syntax.Values.First()); if (attributeSyntax != null && !attributeSyntax.Check(attribute.Vals.Values.Select(v => v.Value).ToList())) { throw new LdapException(string.Format(Global.AttributeSyntaxNotValid, attribute.Type.Value, attributeSyntax.OID), LDAPResultCodes.InvalidAttributeSyntax, dn); } } }
public AddRequestBuilder AddAttribute(string type, ICollection <string> values) { var attribute = new PartialAttribute { Type = new DEROctetString(type), Vals = new DERSet <DEROctetString>() }; foreach (var value in values) { attribute.Vals.Values.Add(new DEROctetString(value)); } _attributes.Values.Add(attribute); return(this); }
public async Task <ICollection <LdapPacket> > Execute(SearchRequestCommand searchRequestCommand) { var searchRequest = searchRequestCommand.ProtocolOperation.Operation as SearchRequest; var dn = searchRequest.BaseObject.Value; var result = new List <LdapPacket>(); if (string.IsNullOrWhiteSpace(dn)) { result.Add(GetRootDSE(searchRequestCommand)); } else { // Ajouter des tests pour la recherche. // Ajouter des tests pour les contrôles. // Externaliser namingContexts // Externaliser subSchemaEntry. var record = await _ldapEntryQueryStore.Get(searchRequest.BaseObject.Value); if (record == null) { throw new LdapException(string.Format(Global.EntryDoesntExist, dn), LDAPResultCodes.NoSuchObject, searchRequest.BaseObject.Value); } var ldapEntries = await _ldapEntryQueryStore.Search(Build(searchRequest)); foreach (var ldapEntry in ldapEntries) { var searchResultEntry = new SearchResultEntry { ObjectName = new DEROctetString(ldapEntry.DistinguishedName) }; foreach (var attr in ldapEntry.Attributes) { if (!searchRequest.Attributes.Values.Any() || searchRequest.Attributes.Values.Any(v => v.Value == "*" || v.Value == attr.Name)) { var partialAttribute = new PartialAttribute { Type = new DEROctetString(attr.Name), Vals = new DERSet <DEROctetString> { Values = attr.Values.Select(s => new DEROctetString(s)).ToList() } }; searchResultEntry.PartialAttributes.Values.Add(partialAttribute); } } result.Add(new LdapPacket { MessageId = searchRequestCommand.MessageId, ProtocolOperation = new DERProtocolOperation { Operation = searchResultEntry } }); } } result.Add(new LdapPacket { MessageId = searchRequestCommand.MessageId, ProtocolOperation = new DERProtocolOperation { Operation = new SearchResultDone { Result = new LDAPResult { MatchedDN = searchRequest.BaseObject, ResultCode = new DEREnumerated <LDAPResultCodes> { Value = LDAPResultCodes.Success }, DiagnosticMessage = new DEROctetString("") } } } }); return(result); }