本文介绍了从VB.NET编辑活动目录中的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的兄弟们朋友,

我在主动目录中写字段方面不是很专家我真的需要你的帮助。

我可以按照以下代码从Active Directory检索用户信息。但我如何授权当前编辑和更新电话号码。此应用程序在sharepoint服务器上运行。



Dear brothers & Friends,
I am not very much expert in writing fields in active directory I really need your help please.
I am able to retrieve user information from Active Directory as per below code. but how can I authorized current to edit and update there telephone numbers. this application is running in sharepoint server.

Dim netBIOSname As String = Me.Page.User.Identity.Name
      Dim sAMAccountName As String = netBIOSname.Substring(netBIOSname.LastIndexOf("\"c) + 1)
      txtuser.Text = sAMAccountName
      Try
          Dim userName As String = txtuser.Text
          Dim searcher As New DirectoryServices.DirectorySearcher( _
             "(mailNickname=" + userName + ")")
          Dim result As DirectoryServices.SearchResult = searcher.FindOne()
          If result Is Nothing Then
              Label2.Text = "Unable to find user: " + userName
          Else
              Dim employee As DirectoryServices.DirectoryEntry = result.GetDirectoryEntry()
              txtfirstname.Text = employee.Properties("givenName").Value.ToString()
              txtlastname.Text = employee.Properties("sn").Value.ToString()
              txtfullname.Text = employee.Properties("cn").Value.ToString()
              txtempid.Text = employee.Properties("physicalDeliveryOfficeName").Value.ToString()
              txttitle.Text = employee.Properties("title").Value.ToString()
              txttele.Text = employee.Properties("telephoneNumber").Value.ToString()
              txtdept.Text = employee.Properties("department").Value.ToString()
              txtmobile.Text = employee.Properties("mobile").Value.ToString()
              Dim ManagerName As String = employee.Properties("manager").Value.ToString()
              ManagerName = ManagerName.Substring(3, ManagerName.IndexOf(",") - 3)
              Dim searchMgr As New DirectoryServices.DirectorySearcher("(cn=" + ManagerName + ")")
              Dim resultMgr As DirectoryServices.SearchResult = searchMgr.FindOne()

              If resultMgr Is Nothing Then
                  Label2.Text = "Unable to find Manager: " + ManagerName
              Else
                  Dim empManager As DirectoryServices.DirectoryEntry = resultMgr.GetDirectoryEntry()
                  searchMgr.Dispose()
                  resultMgr = Nothing
                  empManager.Close()
              End If
              searcher.Dispose()
              result = Nothing
              employee.Close()
          End If


      Catch ex As Exception
          Label2.Text = "The following error occurred: " + ex.Message.ToString()
      End Try





我尝试过:





What I have tried:

retrieve user information from Active Directory 

推荐答案


这篇关于从VB.NET编辑活动目录中的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 10:32