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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 ....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.