Sharpeoint Development

Hello Experts,

I am working on a code (c#) which pulls the user from active directory and then assign user's manager and manager's manager based on conditions..
say if xyz > 1 assign task to user manager
or else user's manager manager
Using Ldap & sAMACCOUNT.
Since I have mentioned about the task there is Sharepoint Moss 2007 custom list asscoiated .
Any suggestion with codes. Please fo let me know if I need to give more information

Thanks in Advance

Who is Participating?
66866Connect With a Mentor Commented:
Here's a function that I have used in one of my workflows. You can use this function for both the scenarios

Private Function getManagersName(ByVal employeesName As String) As String
        Dim managersName As String = String.Empty
        Dim cleanuserName As String = employeesName.Substring(employeesName.LastIndexOf("\\") + 1)
        Dim adFolderobject As DirectoryEntry = New DirectoryEntry
        Dim adSearcherobject As DirectorySearcher = New DirectorySearcher(adFolderobject)
        adSearcherobject.SearchScope = SearchScope.Subtree
        adSearcherobject.Filter = "(CN=" + cleanuserName + ")"
        Dim adobject As SearchResult = adSearcherobject.FindOne
        Dim properties() As String
        If adobject.Properties("Manager").Count > 0 Then
            properties = adobject.Properties("Manager")(0).ToString.Split(",")
            _managerFullName = properties(0).Substring(3)
            managersName = properties(0)
            adSearcherobject.Filter = managersName
            Dim admgrobject As SearchResult = adSearcherobject.FindOne
            Dim mgrUsername As String = admgrobject.Properties("sAMAccountName")(0).ToString
            Dim domain As String = adFolderobject.Name.Substring(3)
            managersName = workflowProperties.Web.SiteUsers(domain + "\" + mgrUsername).ToString
        End If
        Return managersName
    End Function
ranimadinAuthor Commented:

Thanks a lot could you convert the code in c# please

ranimadinAuthor Commented:
thanks a lot
i see that you have closed the question, do you still want it in C#?
ranimadinAuthor Commented:
sure.. I did not know it would be closed ....
All Courses

From novice to tech pro — start learning today.