When you install Exchange and create all your mailboxes by default every mailbox will have POP3,IMAP and HTTP protocols enabled. Good practice is if you don't want people to use these protocols is just disable the protocols on the server which makes the user account settings redundant. But this is not always possible and sometimes you need to leave POP3 and IMAP access enabled for some applications or clients. So to stop people using POP3 and IMAP it can be a good idea to disable that protocol on their Active Directory user account.
To do this via ADSI is not that hard if you keep the following things in mind. The property that controls both these setting is the protocolSettings attribute of the User object. This is a mutli-valued property which also holds the setting for HTTP (OWA Access) as well. By default this property will be blank meaning everything is enabled. Once you disable a protocol a value will get written for that protocol into the property. If you then re-enable the protocol this entry is not deleted rather one bit in the existing property is flipped. For example when I disable IMAP the following gets written into this property.
IMAP4§0§1§4§ISO-8859-1§0§1§0§0 (note because I'm an Aussie we use ISO character sets)
When you re-enable IMAP it just flips the first bit after the protocol IMAP4§0 from 0 to 1 eg
IMAP4§1§1§4§ISO-8859-1§0§1§0§0
So armed with this information to disable pop3 and imap on a mailbox with ADSI, (taking into account nothing has been set for HTTP because this will overwrite that property) you could use the following code (make sure you change the character set to whatever you use)
qstring = "LDAP://CN=USER,OU=wherver,DC=domain,DC=com"
set objUser = GetObject(qstring)
objUser.PutEx 2, "protocolSettings",ARRAY("POP3§0§1§4§ISO-8859-1§0§§§","IMAP4§0§1§4§ISO-8859-1§0§1§0§0")
objUser.setinfo
Flipping it back is a matter of using the same code with the reverse bits
qstring = "LDAP://CN=USER,OU=wherver,DC=domain,DC=com"
set objUser = GetObject(qstring)
objUser.PutEx 2, "protocolSettings",ARRAY("POP3§1§1§4§ISO-8859-1§0§§§","IMAP4§1§1§4§ISO-8859-1§0§1§0§0")
objUser.setinfo
To do this via ADSI is not that hard if you keep the following things in mind. The property that controls both these setting is the protocolSettings attribute of the User object. This is a mutli-valued property which also holds the setting for HTTP (OWA Access) as well. By default this property will be blank meaning everything is enabled. Once you disable a protocol a value will get written for that protocol into the property. If you then re-enable the protocol this entry is not deleted rather one bit in the existing property is flipped. For example when I disable IMAP the following gets written into this property.
IMAP4§0§1§4§ISO-8859-1§0§1§0§0 (note because I'm an Aussie we use ISO character sets)
When you re-enable IMAP it just flips the first bit after the protocol IMAP4§0 from 0 to 1 eg
IMAP4§1§1§4§ISO-8859-1§0§1§0§0
So armed with this information to disable pop3 and imap on a mailbox with ADSI, (taking into account nothing has been set for HTTP because this will overwrite that property) you could use the following code (make sure you change the character set to whatever you use)
qstring = "LDAP://CN=USER,OU=wherver,DC=domain,DC=com"
set objUser = GetObject(qstring)
objUser.PutEx 2, "protocolSettings",ARRAY("POP3§0§1§4§ISO-8859-1§0§§§","IMAP4§0§1§4§ISO-8859-1§0§1§0§0")
objUser.setinfo
Flipping it back is a matter of using the same code with the reverse bits
qstring = "LDAP://CN=USER,OU=wherver,DC=domain,DC=com"
set objUser = GetObject(qstring)
objUser.PutEx 2, "protocolSettings",ARRAY("POP3§1§1§4§ISO-8859-1§0§§§","IMAP4§1§1§4§ISO-8859-1§0§1§0§0")
objUser.setinfo