本文介绍了通过Visual Basic更改公用文件夹的转发地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 你好,推荐答案 Foldertomodify = " [email protected]" addresstoforwardto = " [email protected]" set objmailbox = getobject (" LDAP://" &安培; getPFdn(Foldertomodify)) wscript.echo"转发收件人当前设置为:" &安培; objmailbox.altRecipient objmailbox .altRecipient = getuserdn (addresstoforwardto) wscript.echo"转发收件人更改为:" &安培; objmailbox.altRecipient objmailbox.setinfo function getPFdn(emailaddress) set conn = createobject (" ADODB.Connection") set com = createobject (" ADODB。命令") 设置 iAdRootDSE = GetObject (" LDAP:// RootDSE") strNameingContext = iAdRootDSE 。获取(" defaultNamingContext") Conn.Provider = " ADsDSOObject" Conn.Open" [广告提供商QUOT; mbQuery = "< LDAP://" & strNameingContext&安培; " > ;(&( objectclass = publicFolder )( mail = "& emailaddress&" )); name,distinguishedName; subtree" Com.ActiveConnection = Conn Com.CommandText = mbQuery 设置 Rs = Com 。执行 虽然不是Rs.EOF pfdn = rs 。fields(" distinguishedName") rs.movenext wend getPFdn = pfdn 结束函数 function getuserdn(emailaddress) set conn = createobject (" ADODB.Connection") set com = createobject (" ADODB.Command") 设置 iAdRootDSE = GetObject (" LDAP:// RootDSE") strNameingContext = iAdRootDSE .Get(" defaultNamingContext") Conn.Provider = " ADsDSOObject" Conn.Open"ADs Provider" mbQuery = "< LDAP://" & strNameingContext&安培; " > ;(&( objectclass = user )( mail = "& emailaddress&" )); name,distinguishedName; subtree" Com.ActiveConnection = Conn Com.CommandText = mbQuery 设置 Rs = Com 。执行 虽然不是Rs.EOF Userdn = rs 。fields(" distinguishedName") rs.movenext wend getuserdn = userdn 结束函数Foldertomodify = "[email protected]" addresstoforwardto = "[email protected]"  set objmailbox = getobject("LDAP://" & getPFdn(Foldertomodify))  wscript.echo "Forwarding Recipient currently set to : " & objmailbox.altRecipient  objmailbox.altRecipient = getuserdn(addresstoforwardto)  wscript.echo "Forwarding Recipient changed to : " & objmailbox.altRecipient  objmailbox.setinfo   function getPFdn(emailaddress)    set conn = createobject("ADODB.Connection")  set com = createobject("ADODB.Command")  Set iAdRootDSE = GetObject("LDAP://RootDSE")  strNameingContext = iAdRootDSE.Get("defaultNamingContext")  Conn.Provider = "ADsDSOObject" Conn.Open "ADs Provider"  mbQuery = "<LDAP://" & strNameingContext & ">;(&(objectclass=publicFolder)(mail=" & emailaddress & "));name,distinguishedName;subtree"  Com.ActiveConnection = Conn  Com.CommandText = mbQuery Set Rs = Com.Execute  While Not Rs.EOF  pfdn = rs.fields("distinguishedName")  rs.movenext  wend   getPFdn = pfdn  end function   function getuserdn(emailaddress)    set conn = createobject("ADODB.Connection")  set com = createobject("ADODB.Command")  Set iAdRootDSE = GetObject("LDAP://RootDSE")  strNameingContext = iAdRootDSE.Get("defaultNamingContext")  Conn.Provider = "ADsDSOObject" Conn.Open "ADs Provider"  mbQuery = "<LDAP://" & strNameingContext & ">;(&(objectclass=user)(mail=" & emailaddress & "));name,distinguishedName;subtree"  Com.ActiveConnection = Conn  Com.CommandText = mbQuery Set Rs = Com.Execute  While Not Rs.EOF  Userdn = rs.fields("distinguishedName")  rs.movenext  wend   getuserdn = userdn   end function    这篇关于通过Visual Basic更改公用文件夹的转发地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 02:46