2013-01-03 75 views
0

我有一个页面中使用VB.NET 我用下面的代码.Invoke(“SetPassword”,...)导致的“RPC服务器不可用”错误

Dim rootEntry As New DirectoryEntry 
With rootEntry 
    .Path = "LDAP://" & strServer & "/" & strLDAP 
    .AuthenticationType = AuthenticationTypes.Secure 
    .Username = strServerUsername 
    .Password = strServerPassword 
End With 



Dim newUser As DirectoryEntry = rootEntry.Children.Add("CN=" & strCN, "user") 
With newUser 
    .CommitChanges() 
    .Properties("userPrincipalName").Value = TextPN.Text 
    .Properties("sAMAccountName").Value = TextAlias.Text 
    .Properties("givenname").Value = TextGivenname.Text 
    .Properties("sn").Value = TextSurname.Text 
    …… 
    .CommitChanges() 

    .Invoke("setPassword", New Object() {strDefaultPassword}) 
    .CommitChanges() 
    .Properties("userAccountControl").Value = &H0001 
    .CommitChanges()   
End With 
我们的活动目录创建新用户

此代码在过去运行良好。 现在我们已经将我们的网络服务器迁移到Windows Server 2008 R2和IIS 7.5,并且代码突然不再工作了。 (.net framework为2.0,无法更改) 用户仍在我们的活动目录中创建,但该帐户被自动禁用,并且未设置密码。

调查这个问题显示,一个例外是在线抛出

.Invoke("setPassword", New Object() {strDefaultPassword}) 

异常

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 

其用于连接到AD的用户帐户仍然是相同的并具有域管理权利。 由于代码没有任何改变,我认为必须有另一个原因,为什么这不工作了?防火墙设置,IIS配置,..?

任何想法??

我知道这里有类似的情况Trying to create a new Active Directory user, Invoke("SetPassword",pwd) throws "The RPC server is unavailable" ,但这并没有帮助我。

回答

1

检查TCP/UDP 445端口是否在防火墙上打开。 要从域外连接到AD服务器,需要打开以下端口: 。 TCP/UDP 389(LDAP) 。 TCP 3268(GC) 。 TCP/UDP 445(SMB over IP)

0

DirectoryEntry.Invoke()要求AuthenticationType.Secure。这意味着它需要能够通过Kerberos或NTLM验证请求。

它首先尝试使用LDAPS(TCP 636),然后如果/由于证书丢失或无效而超时或失败,则会回退到CiFS(TCP445)。如果这两个端口均未打开,则它将失败并出现“RPC服务器不可用”异常。

相关问题