Hi,

I've started on a simple server ROP (GetAddressTypes from MS-OXOMSG), and my
 initial version works (in that the relevant part of mapitest passes when I run
against it). However to get to that point, I've hard coded the responses (to be
three strings "SMTP", "EX" and "X400". The code is attached.

I recognise that the appropriate address types should come from the server
configuration, but I'm not sure how to do that.

In setup/AD/oc_provision_configuration.ldif, I see a range of address template
entries that are variations on this snipped (that very for different languages):
#
# Arabic Address-Templates
#
dn: CN=401,CN=Address-Templates,CN=Addressing,${FIRSTORGDN}
objectClass: top
objectClass: container
cn: 401
distinguishedName: CN=401,CN=Address-Templates,CN=Addressing,${FIRSTORGDN}
instanceType: 4
displayName: Arabic
showInAdvancedViewOnly: TRUE
adminDisplayName: Arabic
name: 401
legacyExchangeDN: 
/o=${FIRSTORG}/CN=Configuration/CN=Addressing/CN=Address-Templates/CN=401
objectCategory: CN=Container,${SCHEMADN}
msExchTemplateRDNs: CCMAIL
msExchTemplateRDNs: MSA
msExchTemplateRDNs: SMTP
msExchTemplateRDNs: MS
msExchTemplateRDNs: x400

If I understand the provisioning code, that is supposed to go into the "sam
database", and I see similar stuff in
private/sam.ldb.d/CN=CONFIGURATION,DC=OPENCHANGE,DC=LOCAL.ldb,
like
# record 1534
dn: CN=401,CN=Address-Templates,CN=Addressing,CN=First 
Organization,CN=Microsoft 
Exchange,CN=Services,CN=Configuration,DC=openchange,DC=local
objectClass: top
objectClass: container
cn: 401
instanceType: 4
whenCreated: 20100303012009.0Z
whenChanged: 20100303012009.0Z
displayName: Arabic
uSNCreated: 4467
uSNChanged: 4467
showInAdvancedViewOnly: TRUE
adminDisplayName: Arabic
nTSecurityDescriptor: O:SYG:BAD:AI(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;S-1-5-21-38
 18482191-3036200400-525829622-512)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)(A;;RPL
 CLORC;;;AU)(A;CIID;RPWPCRCCDCLCLORCWOWDSDDTSW;;;S-1-5-21-3818482191-303620040
 0-525829622-519)(A;CIIOID;RPWPCRCCLCLORCWOWDSDSW;;;S-1-5-21-3818482191-303620
 0400-525829622-512)
name: 401
objectGUID: 21ccf757-5d48-4aff-8831-b50a108b1e55
replPropertyMetaData:: AQAAAAAAAAAMAAAAAAAAAAAAAAABAAAASUqeAQMAAAClrbUgtfjWRIo
 7zQVHBFrhcxEAAAAAAABzEQAAAAAAAAEAAgABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEA
 AAAAAABzEQAAAAAAAAIAAgABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAA
 AAAAA0AAgABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAAKkAAgABAA
 AASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAAMIAAgABAAAASUqeAQMAAAC
 lrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAABkBAgABAAAASUqeAQMAAAClrbUgtfjWRIo7
 zQVHBFrhcxEAAAAAAABzEQAAAAAAAAEACQABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAA
 AAAAABzEQAAAAAAAI8CCQABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAA
 AAAA4DCQABAAAASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAAEEAIwABAAA
 ASUqeAQMAAAClrbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAAAMAAAABAAAASUqeAQMAAACl
 rbUgtfjWRIo7zQVHBFrhcxEAAAAAAABzEQAAAAAAAA==
legacyExchangeDN: /o=First Organization/CN=Configuration/CN=Addressing/CN=Addr
 ess-Templates/CN=401
objectCategory: <GUID=13c1a642-b588-47b3-a90d-7f08ff3dc0ac>;CN=Container,CN=Sc
 hema,CN=Configuration,DC=openchange,DC=local
msExchTemplateRDNs: CCMAIL
msExchTemplateRDNs: MSA
msExchTemplateRDNs: SMTP
msExchTemplateRDNs: MS
msExchTemplateRDNs: x400
distinguishedName: CN=401,CN=Address-Templates,CN=Addressing,CN=First Organiza
 tion,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=openchange,DC=loca
 l


So I guess there is some ldb query that I have to make. There are two parts
to this:
Q1. How do I get the right language code (from the client request, or some
server configuration, or something else)?
Q2. Is there an example of how to do the query and parse the results?

Brad
Index: mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.c
===================================================================
--- mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.c	(revision 1754)
+++ mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.c	(working copy)
@@ -386,6 +386,12 @@
 								    &(mapi_response->mapi_repl[idx]),
 								    mapi_response->handles, &size);
 			break;
+		case op_MAPI_AddressTypes:
+			retval = EcDoRpc_RopGetAddressTypes(mem_ctx, emsmdbp_ctx,
+							    &(mapi_request->mapi_req[i]),
+							    &(mapi_response->mapi_repl[idx]),
+							    mapi_response->handles, &size);
+			break;
 		case op_MAPI_Logon:
 			retval = EcDoRpc_RopLogon(mem_ctx, emsmdbp_ctx,
 						  &(mapi_request->mapi_req[i]),
Index: mapiproxy/servers/default/emsmdb/oxcstor.c
===================================================================
--- mapiproxy/servers/default/emsmdb/oxcstor.c	(revision 1754)
+++ mapiproxy/servers/default/emsmdb/oxcstor.c	(working copy)
@@ -330,3 +330,55 @@
 
 	return retval;
 }
+
+
+/**
+   \details EcDoRpc GetAddressTypes (0x49) Rop. This operation gets
+   the valid address types (e.g. "SMTP", "X400", "EX")
+
+   \param mem_ctx pointer to the memory context
+   \param emsmdbp_ctx pointer to the emsmdb provider context
+   \param mapi_req pointer to the AddressTypes EcDoRpc_MAPI_REQ
+   \param mapi_repl pointer to the AddressTypes EcDoRpc_MAPI_REPL
+   \param handles pointer to the MAPI handles array
+   \param size pointer to the mapi_response size to update
+
+   \return MAPI_E_SUCCESS on success, otherwise MAPI error
+ */
+_PUBLIC_ enum MAPISTATUS EcDoRpc_RopGetAddressTypes(TALLOC_CTX *mem_ctx,
+						    struct emsmdbp_context *emsmdbp_ctx,
+						    struct EcDoRpc_MAPI_REQ *mapi_req,
+						    struct EcDoRpc_MAPI_REPL *mapi_repl,
+						    uint32_t *handles, uint16_t *size)
+{
+	enum MAPISTATUS		retval = MAPI_E_SUCCESS;
+
+	DEBUG(4, ("exchange_emsmdb: [OXCSTOR] AddressTypes (0x49)\n"));
+
+	/* Sanity checks */
+	OPENCHANGE_RETVAL_IF(!emsmdbp_ctx, MAPI_E_NOT_INITIALIZED, NULL);
+	OPENCHANGE_RETVAL_IF(!mapi_req, MAPI_E_INVALID_PARAMETER, NULL);
+	OPENCHANGE_RETVAL_IF(!mapi_repl, MAPI_E_INVALID_PARAMETER, NULL);
+	OPENCHANGE_RETVAL_IF(!handles, MAPI_E_INVALID_PARAMETER, NULL);
+	OPENCHANGE_RETVAL_IF(!size, MAPI_E_INVALID_PARAMETER, NULL);
+	
+	/* TODO: fetch from the server configuration instead of hard-coding this */
+	mapi_repl->opnum = mapi_req->opnum;
+	mapi_repl->handle_idx = mapi_req->handle_idx;
+	mapi_repl->error_code = retval;
+	mapi_repl->u.mapi_AddressTypes.cValues = 3;
+	mapi_repl->u.mapi_AddressTypes.size = 0;
+	mapi_repl->u.mapi_AddressTypes.transport = talloc_array(mem_ctx, struct mapi_LPSTR, mapi_repl->u.mapi_AddressTypes.cValues);
+	mapi_repl->u.mapi_AddressTypes.transport[0].lppszA = talloc_asprintf(mem_ctx, "%s", "SMTP");
+	mapi_repl->u.mapi_AddressTypes.size += (strlen(mapi_repl->u.mapi_AddressTypes.transport[0].lppszA) + 1);
+	mapi_repl->u.mapi_AddressTypes.transport[1].lppszA = talloc_asprintf(mem_ctx, "%s", "X400");
+	mapi_repl->u.mapi_AddressTypes.size += (strlen(mapi_repl->u.mapi_AddressTypes.transport[1].lppszA) + 1);
+	mapi_repl->u.mapi_AddressTypes.transport[2].lppszA = talloc_asprintf(mem_ctx, "%s", "EX");
+	mapi_repl->u.mapi_AddressTypes.size += (strlen(mapi_repl->u.mapi_AddressTypes.transport[2].lppszA) + 1);
+
+	*size = libmapiserver_RopGetAddressTypes_size(mapi_repl);
+
+	handles[mapi_repl->handle_idx] = handles[mapi_req->handle_idx];
+
+	return retval;
+}
Index: mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.h
===================================================================
--- mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.h	(revision 1754)
+++ mapiproxy/servers/default/emsmdb/dcesrv_exchange_emsmdb.h	(working copy)
@@ -164,6 +164,7 @@
 enum MAPISTATUS	EcDoRpc_RopLogon(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, struct EcDoRpc_MAPI_REPL *, uint32_t *, uint16_t *);
 enum MAPISTATUS	EcDoRpc_RopRelease(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, uint32_t *, uint16_t *);
 enum MAPISTATUS	EcDoRpc_RopGetReceiveFolder(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, struct EcDoRpc_MAPI_REPL *, uint32_t *, uint16_t *);
+enum MAPISTATUS	EcDoRpc_RopGetAddressTypes(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, struct EcDoRpc_MAPI_REPL *, uint32_t *, uint16_t *);
 
 /* definition from oxctabl.c */
 enum MAPISTATUS EcDoRpc_RopSetColumns(TALLOC_CTX *, struct emsmdbp_context *, struct EcDoRpc_MAPI_REQ *, struct EcDoRpc_MAPI_REPL *, uint32_t *, uint16_t *);
Index: mapiproxy/libmapiserver/libmapiserver_oxcstor.c
===================================================================
--- mapiproxy/libmapiserver/libmapiserver_oxcstor.c	(revision 1754)
+++ mapiproxy/libmapiserver/libmapiserver_oxcstor.c	(working copy)
@@ -83,3 +83,26 @@
 
 	return size;
 }
+
+
+/**
+   \details Calculate GetAddressTypes (0x49) Rop size
+
+   \param response pointer to the GetAddressTypes EcDoRpc_MAPI_REPL structure
+
+   \return Size of GetAddressTypes response
+ */
+_PUBLIC_ uint16_t libmapiserver_RopGetAddressTypes_size(struct EcDoRpc_MAPI_REPL *response)
+{
+	uint16_t	size = SIZE_DFLT_MAPI_RESPONSE;
+
+	if (!response || response->error_code) {
+		return size;
+	}
+
+	size += SIZE_DFLT_ROPGETADDRESSTYPES;
+	/* The length of the strings is variable, but given by the size parameter */
+	size += response->u.mapi_AddressTypes.size;
+
+	return size;
+}
Index: mapiproxy/libmapiserver/libmapiserver.h
===================================================================
--- mapiproxy/libmapiserver/libmapiserver.h	(revision 1754)
+++ mapiproxy/libmapiserver/libmapiserver.h	(working copy)
@@ -142,6 +142,13 @@
 #define	SIZE_DFLT_ROPGETRECEIVEFOLDER		8
 
 /**
+   \details GetAddressTypes has fixed response size for:
+   -# cValues: uint16_t
+   -# size: uint16_t
+ */
+#define	SIZE_DFLT_ROPGETADDRESSTYPES		4
+
+/**
    \details FindRow has fixed response size for:
    -# RowNoLongerVisible: uint8_t
    -# HasRowData: uint8_t
@@ -201,6 +208,7 @@
 uint16_t libmapiserver_RopLogon_size(struct EcDoRpc_MAPI_REQ *, struct EcDoRpc_MAPI_REPL *);
 uint16_t libmapiserver_RopRelease_size(void);
 uint16_t libmapiserver_RopGetReceiveFolder_size(struct EcDoRpc_MAPI_REPL *);
+uint16_t libmapiserver_RopGetAddressTypes_size(struct EcDoRpc_MAPI_REPL *);
 
 /* definitions from libmapiserver_oxctabl.c */
 uint16_t libmapiserver_RopSetColumns_size(struct EcDoRpc_MAPI_REPL *);
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to