/// <summary> /// Creates a SearchResultEntry packet. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="matchedDn">Matched DN.</param> /// <param name="attributes">The attributes and values that are contained in the entry.</param> /// <returns>The packet that contains the response.</returns> internal override AdtsSearchResultEntryPacket CreateSearchedResultEntry( AdtsLdapContext context, string matchedDn, params KeyValuePair <string, string[]>[] attributes) { int length = (attributes != null) ? attributes.Length : 0; PartialAttributeList_element[] partialAttributeElementArray = new PartialAttributeList_element[length]; for (int i = 0; i < length; i++) { partialAttributeElementArray[i] = new PartialAttributeList_element( new AttributeDescription(attributes[i].Key), CreateAttributeValueSet(attributes[i].Value)); } PartialAttributeList attributeList = new PartialAttributeList(partialAttributeElementArray); SearchResultEntry entry = new SearchResultEntry( new LDAPDN(matchedDn ?? string.Empty), attributeList); LDAPMessage_protocolOp operation = new LDAPMessage_protocolOp(); operation.SetData(LDAPMessage_protocolOp.searchResEntry, entry); LDAPMessage message = new LDAPMessage(new MessageID(context.MessageId), operation, null); AdtsSearchResultEntryPacket packet = new AdtsSearchResultEntryPacket(); packet.ldapMessagev3 = message; packet.messageId = context.MessageId; return(packet); }
public SearchResultEntry( LDAPDN objectName, PartialAttributeList attributes) { this.objectName = objectName; this.attributes = attributes; }
/// <summary> /// Creates a SearchResultEntry packet. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="matchedDn">Matched DN.</param> /// <param name="attributes">The attributes and values that are contained in the entry.</param> /// <returns>The packet that contains the response.</returns> internal override AdtsSearchResultEntryPacket CreateSearchedResultEntry( AdtsLdapContext context, string matchedDn, params KeyValuePair<string, string[]>[] attributes) { int length = (attributes != null) ? attributes.Length : 0; PartialAttributeList_element[] partialAttributeElementArray = new PartialAttributeList_element[length]; for (int i = 0; i < length; i++) { partialAttributeElementArray[i] = new PartialAttributeList_element( new AttributeDescription(attributes[i].Key), CreateAttributeValueSet(attributes[i].Value)); } PartialAttributeList attributeList = new PartialAttributeList(partialAttributeElementArray); SearchResultEntry entry = new SearchResultEntry( new LDAPDN(matchedDn ?? string.Empty), attributeList); LDAPMessage_protocolOp operation = new LDAPMessage_protocolOp(); operation.SetData(LDAPMessage_protocolOp.searchResEntry, entry); LDAPMessage message = new LDAPMessage(new MessageID(context.MessageId), operation, null); AdtsSearchResultEntryPacket packet = new AdtsSearchResultEntryPacket(); packet.ldapMessagev3 = message; packet.messageId = context.MessageId; return packet; }