|
|
|||||||
We have an issue where it would be great if a user could set his/her own default e-mail address. Let’s say a user has three e-mail addresses one is the default and the other two are aliases. Is it then possible to set the default as an alias and set an alias as the default via a script? Did some googling on this but did not find anything useful yet. |
||||||||
|
|
|||||||
I think the way PayPal handles this, for example.. They send an e-mail to all of the addresses you define. The only purpose that I can see with this (personally).. If you forget your password and need to have it send you the unlock link and your e-mail address has changed.. Thanks, Kent |
||||||||
|
|
|||||||
Hi Kent. Long time no see. Hope all is ok. Maybe I should explain this a bit more. Some of our employees work for our OfficeA and OfficeB but are employed by OfficeA so user@OfficeA.nl is the default e-mail address on our exchange server. When they do work for OfficeB and therefore need to send an e-mail to a customer or supplier they want to send it from user@OfficeB.nl. Sure you can use the from field in outlook but that automatically translates to your default e-mail address and does not hold the address if you typed an alias in the from field. One way to "fix" this without me switching it in AD 10 times a day would be to create an kixforms app that the user can fire up, list all e-mail addresses he/she has, select the one to be default, click ok and have the script switch the current default to an alias and set the selected address as default. Just like you can do in the e-mail addresses tab in the user’s properties in AD. Oh BTW we use Win2K and Exchange 2K just in case stuff is a bit different in 2K3 or even 2K8. |
||||||||
|
|
|||||||
I found something interesting... will pass this along asap. [Edit... I've come up with some UDFs, but will try to test with Mart, before posting] |
||||||||
|
|
|||||||
Oooohhh... sounds good. I'd be happy do do some testing. I just send you a PM. |
||||||||
|
|
|||||||
Got something going to get all e-mail addresses some time ago. Only thing missing is the code to change an alias into the default and the default into an alias. Code: Break on $rc = SetOption('Explicit','On') $rc = SetOption('NoVarsInStrings','On') $rc = SetOption('NoMacrosInStrings','On') Dim $adsDomain, $adsUser, $cnusr, $usrnfo, $usrmail, $type $adsDomain = GetObject("WinNT://"+@LDOMAIN) $adsDomain.filter = "User","" For Each $adsUser in $adsDomain $cnusr = TranslateName($adsUser.Name) $usrnfo = GetObject("LDAP://"+$cnusr) For Each $usrmail in $usrnfo.proxyAddresses If Left($usrmail, 5) <> "X400:" If $adsUser.Name = @USERID $type = Left($usrmail, 3) If LCase($type) == $type $type = "Alias" Else $type = "Default" EndIf ? $adsUser.Name " : " $usrmail " : " $type EndIf EndIf Next Next Sleep 5 Function TranslateName($NameToTranslate) Dim $NameTranslate $NameTranslate = CreateObject("NameTranslate") $NameTranslate.Init(3,"") $NameTranslate.Set(3, @LDOMAIN + "\" + $NameToTranslate) $TranslateName = $NameTranslate.Get(1) EndFunction |
||||||||
|
|
|||||||
[edit] Removed stupid code. Examples below are much nicer. [/edit] |
||||||||
|
|
|||||||
Okay... here is what I have... the start of 3 new UDFs. The getUserDN may already exist somewhere [edit: ahh... so this is what TranslateName() does. /edit], so I may have reinvented the wheel. The UDFs still need some cleanup, debugging, etc, but should be working. As we discussed, the AD perms may be an issues with the SET udf. |
||||||||
|
|
|||||||
Sweet I'll look into it today and let you know how it comes along. |
||||||||
|
|
|||||||
Allen, Very cools stuff. Works great But like you said a regular user cannot set his/her default e-mail address. I did some testing with a user I created especially for this and it did work when on the security tab in the user's properties in AD I added write to SELF. A security risk, I know. I’m looking at the consequences that this might have. Hmmmmmm… |
||||||||
|
|
|||||||
Made a KF.NET GUI around this. It’s not completely done just yet but I’ll post the code later this week. What does it do?
|
||||||||
|
|
|||||||
So Mart / Allen I notice that you went with the the SMTP entry as being the default e-mail. Was there no way to read the "mail" entry? It looks like this might be returned as an object instead of a string though. |
||||||||
|
|
|||||||
In this case, Mart was looking to get all the email addresses, AND the default. The uppercase SMTP is always supposed to be the default, so it kind of was just a matter of checking it. .mail should be no different though. |
||||||||
|
|
|||||||
@Mart... would you mind testing these versions out... I added some error checking/etc. |
||||||||
|
|
|||||||
Allen, Would you mind eloborating on the "ADSystemInfo" object. I have only worked really with the "WinNT" and "LDAP" objects. I am assuming that this line of your code "$objUser=getobject("LDAP://" + $objSysInfo.UserName)" is returning the the entire User properties. Else how is it that the ".proxyaddresses" is being returned as an array within the properties of the user. I can trust that the code you have works (it usually does), but want a better understanding of what I am working with. Many thanks G |
||||||||
|
|
|||||||
Code: $objSysInfo = CreateObject("ADSystemInfo") $objUser=getobject("LDAP://" + $objSysInfo.UserName) When you are only interested in the current user, this is just a different way/shortcut to get the DN, rather than using the TranslateName UDF (nametranslate object) . Truthfully, you could use the Translatename exclusively if you wanted to. Its creating two objects, one with the ADSystemInfo, and then another when you use the LDAP provider with .username. This gives you all the properties of the current user, including the proxyaddresses. Clear as mud? |
||||||||
|
|
|||||||
Quote: @Mart... would you mind testing these versions out... I added some error checking/etc. .... Will do but it will have to wait until tomorrow. I’m in the office for just a few hours today and some work is waiting. |
||||||||
|
|
|||||||
Allen, They seem to work just fine. The reason why I didn't post the GUI code yet is that I get loads of return codes on the screen when lines are added to a ComboBox. Couldn't find the reason for this yet have to figure that one out. |
||||||||
|
|
|||||||
Cool... thanks for testing them. What have you guys decided on the perms? The reason I ask is... I have another UDF that might make you reconsider allowing changes |
||||||||
|
|
|||||||
We decided not to change any perms until the user needs to be able to change his/her default address then we give the SELF user write privileges. As soon as he/she no longer needs this we remove the permissions and set it back to how it was before the change (default is read only). So you have an other UDF that will make me reconsider? Hmmmm....wathya doing? Trying to make me cry? |