C#怎样给AD用户建立Exchange邮箱(不用CDOEXM) (转)_涅磐飞升的
空间_百度空间C# how to AD users to establish a Exchangemailbox (not CDOEXM) (to) _ Nirvana soaring space _ Baiduspace
C#how to AD users to establish a Exchange mailbox (not CDOEXM)(turn) space Baidu space _Username: Password: _ Nirvanasoaring soaring space home page login Nirvana
Blogs, albums, personal files, good friends
View Article
How does C#create Exchange mailboxes (not CDOEXM) for AD users?2010-08-31 23:48
These days have also been CDOEXM torture a, in accordance withthe following standard method of MSDN, add bird reference toCDOEXM, and my cdo.dll, cdoexm.dll are exchange
2000 work on the server copy down, and then use the followingMSDN to provide the code, reported wrong, always reported wrong,a road to the black newspaper error! Say yes:
System.Runtime. InteropServices.COMException (0x80072030) :there is no such object on the server.
Mailbox = (IMailboxStore) user.NativeObject;
Mailbox.CreateMailbox (homeMDB) ;
User.CommitChanges () ;
I can be sure that the homeMDB extended attribute value mustbe wrong, because it is derived directly from Microsoft' s ownwindows vbs script system to a text file, vbs script, behindwill use the export homeMTA and msExchHomeServerName
StrBranchName= "OU name 1, OU=OU name 0, OU= company OU"""There is only one mailbox user below the Ou of the upper layersof the path. "
StrDC= "gdmailclus1"' IIS server name
StrDomain= "DC=mail, DC=xxxx", 'AD server, DN
S trLDAP=, "<LDAP://", "+s trDC+", "/OU=", "+st rBranchName+","+strDomain+" >"
Set oLDAPConn = CreateObject ("AdoDB.Connection")
OLDAPConn.Provider = "AdsDSOObj ect""
OLDAPConn.open
Set oCmd = CreateObject ("AdoDB.Command")
OCmd.ActiveConnecti on = oLDAPConn
OCmd.CommandT ext =
"StrLDAP+"; (objectCategory=Person) ; Distingui shedName; mail;SubTree"
Set oResult = oCmd.Execute
Set FSO=Wscript.CreateObject ("Scripting.FileSystemObject")"Set f = fso.CreateTextFile" ("C:\Documents and"
Sett ings\szadmin\ desktop \homeMDB.txt ""
StrGetUser= "LDAP://", "+strDC+" / "+oResult.Fields (0)"Set oUser = GetObject (strGetUser)
'wscript.echo
StrGetUser+vbcrlf+ "name:", "+oUser.name+vbcrlf+",
"sAMAccountName:", "+oUser. sAMAccountName+vbcrlf+",
"serverName:", "+oUser. serverName+vbcrl f+", "Mai l:",
"+oUser.Ma i l"
F.Wr iteLine (oUs er.homeMDB)
'wscript.echo oUser.homeMDB
'wscript.echo oUser.homeMTA
'wscript.echo oUser.mailNickName
'wscript.echo oUser.msExchUserAccountControl
'wscript.echo oUser.msExchHomeServerName
'wscript.echo oUser.mDBUseDefaults
'wscript.echo oUser.mail
F.close
Moreover, I can not work in the exchange server on thedevelopment environment, can not debug, and had to find a wayonline. Later on the Internet finally found, the originalCDOEXM in C# is not good, the conversion step error, adjustinga GetObject VB.net method on the OK, I also like the same problem,that is to the changed VB.net well.
God, I completely fainted at this point, the admiration ofMicrosoft, once again rising birds, are their own East and West,can do so. .
Fortunately, later found in a thread inside the method, theoriginal need not CDOEXM this rotten Dongdong, you can completethe construction of exchange mailbox work, directly write a fewAD extensions properties can be birds, the code is as follows:User.Properti es["homeMDB"] .Value=homeMDB;
User.Properti es["homeMTA"] .Value=homeMTA;
User.Properties["mailNickName", "] .Add" (dr["UserID",
"] .ToString") ;
User.Properties["msExchUserAccountControl", ] .Add (0) ;User.Properti es["msExchHomeServerName", "] .Add"
("/o=MAIL001/ou=mai ladmin/cn=Configurat ion/cn=Servers/cn=Mai l-SERVER") ;
User.Properti es["mDBUseDefaults", "] .Add" ("TRUE") ;
User.CommitChanges () ;
User is a DirectoryEntry object instance that you find, and Dris a DataRow in the input data set
HomeMDB, homeMTA, and msExchHomeServerName can be obtainedfrom the server using the above vbs script, and thestrBranchName in the script is changed to suit you
These three parameters of mine are as follows:
Private, string, homeMDB =
"CN=BE-SG2-MDB1, CN=GDMAI L-SG2, CN=I nformat i onSt ore,
CN=GDMAILEXCH, CN=Servers, CN=, the first management group,CN=Administrative
Groups, CN=xxxxORG, CN=Mi crosof t
Exchange, CN=Services, CN=Conf i gurat ion, DC=mai l, DC=xxxx";
Private string homeMTA = "CN=Microsoft"
MTA, CN=GDMAILEXCH, CN=Servers, CN=, the f irst managementgroup, CN=Admini strative
Groups, CN=xxxxORG, CN=Mi crosof t
Exchange, CN=Services, CN=Conf i gurat ion, DC=mai l, DC=xxxx";Private, string, msExchHomeServerName =
"/o=GMCCORG/ou=GDMAILEXAG/cn=Conf i gurat ion/cn=Servers/cn=GDMAILEXCH. "";
Trying to write the mail attribute in our work environment doesnot cause a constraint conflict exception, so you can changethe default mail address in batches by another VBS script.Change the default mail address of VBS:
StrBranchName= "Shenzhen branch""
S trBranchDoma in= "s z. ""
StrAll= "gd.xxxx.com""
StrDC= "gdmailclus1""
StrDomain= "DC=mai l, DC=xxxx. ""
S trLDAP=, "<LDAP://", "+s trDC+", "/OU=", "+st rBranchName+",
"+strDomain+" >"
Set oLDAPConn = CreateObject ("AdoDB.Connection")
OLDAPConn.Provider = "AdsDSOObj ect""
OLDAPConn.open
Set oCmd = CreateObject ("AdoDB.Command")
OCmd.ActiveConnecti on = oLDAPConn
OCmd.CommandT ext =
"StrLDAP+"; (objectCategory=Person) ; Distingui shedName; mail;SubTree"
Set oResult = oCmd.Execute
Wscript.echo oResult.Recordcount
While not oResult.EOF
StrGetUser= "LDAP://", "+strDC+" / "+oResult.Fields (0)"Set oUser = GetObject (strGetUser)
'wscript.echo oUser.name
OldMai l=oUser.mai l
If (Len (OldMail) >0) Then
OldPrimaryEmai l=Join (oUser.proxyAddres ses, "!")
INotChange=inStr (OldPrimaryEmai l, SMTP: , +oUser. )
“@” strbranchdomain sAMAccountName + + +稻草
如果inotchange = 0然后oldprimaryemai l =取代ol dprimaryemai l “即” “即” oldprimaryemail =取代oldprimaryemail ”即“+ ouser。sAMAccountName + “@” + strbranchdomai n +稻草 ”即“+ ouser。sAMAccountName + “@” + strbranchdoma in +稻草newmai l = ouser。 sAMAccountName + “@” + strbranchdomain +稻草
“wscript. echo”邮件 “+ newmail
“wscript. echo”代理 “+ oldprimaryemailstrproxy =分裂oldprimaryemail “ ” ouser。 msexchpoliciesexcluded
= “{ 26491cfc-9e50-4857-861b-0cb8df22b5d7 }”
“ouser msexchpoliciesexcluded = vbnull。ouser邮件= newmai l。
ouser ProxyAddresses = strproxy。ouser. setinfo
最后如果
最后如果oresult.movenext
走wscript.echo “完成”
上一篇> > C #创建交换邮箱问题请教高„下一篇> > c doexm操作转kaneboy
类别 A SP.NET | |添加到搜藏|分享到我贴吧|浏览474 |评论网友评论
该篇文章没有任何评论。
发表评论
内容
取消回复
推荐文章
香港云服务器最便宜价格是多少钱一个月/一年?无论香港云服务器推出什么类型的配置和活动,价格都会一直吸引我们,那么就来说说香港最便宜的云服务器类型和香港最低的云服务器价格吧。香港云服务器最便宜最低价的价格是多少?香港云服务器只是服务器中最受欢迎的产品。香港云服务器有多种配置类型,如1核1G、2核2G、2核4G、8到16核32G等。这些配置可以满足大多数用户的需求,无论是电商站、视频还是游戏、小说等。...
由于行业需求和自媒体的倾向问题,对于我们个人站长建站的方向还是有一些需要改变的。传统的个人网站建站内容方向可能会因为自媒体的分流导致个人网站很多行业不再成为流量的主导。于是我们很多个人网站都在想办法进行重新更换行业,包括前几天也有和网友在考虑是不是换个其他行业做做。这不有重新注册域名重新更换。鉴于快速上手的考虑还是采用香港服务器,这不腾讯云和阿里云早已不是新账户,考虑到新注册UCLOUD账户还算比...
hostkvm在2021年3月新上线洛杉矶新VPS业务,强制三网接入中国联通优化线路,是当前中美之间性价比最高、最火热的线路之一,性价比高、速度非常好,接近联通AS9929和电信AS4809的效果,带宽充裕,晚高峰也不爆炸。 官方网站:https://hostkvm.com 全场优惠码:2021(全场通用八折,终身码,长期) 美国 US-Plan0【三网联通优化线路】 内存:1G CPU:...