Others
Account does not have permission to open the attachment : Hyper-V VM Error
Category: #D365,Account does not have permission to open the attachment,D365Champs,Hyper-V,Microsoft Dynamics CRM,Others,Virtual Machine,VM Error Author: Ashwani Ashwin Date: 6 months ago Comments: 0

Hello Everyone, My CRM servers are distributed to 3 VM’s: Web, App and DB individually. All these 3 VM’s are …

Continue reading

Source: Ashwani Ashwin


LDAP Query : Fetch User information from Active Directory in different Domain Controller
Category: D365Champs,Others Author: Ashwani Ashwin Date: 8 months ago Comments: 0

Hello Everyone,

 

This week I got a task to perform a LDAP query and fetch few user information. Challenge was to perform the fetch action not from our current domain but rather a different domain; that too not with FQDN but with IP. This was not too tricky as all I need to do was configure the DirectoryEntity first and then pass it to the usual DirectorySearcher which we use to perform LDAP.

 

Let me explain that in detail, step by step:

 

1> I started with creating a new Console App in Visual Studio.

 

2>  To begin with, I needed to add the System.DirectoryServices (for LDAP) and System.Configurations (for configuration file) as assembly references. 

 

3> Initialize the DirectoryEntity object with the following:

    • Authenticating accountId
    • Authenticating Password
    • LDAP path (can either be Server IP containing AD <“LDAP://10.10.10.10”> or the FQDN of AD <“LDAP://DC=mscrm,DC=com,DC=sg”>)

 

4>  Initialize the DirectorySearcher object with the DirectoryEntry.

This would do a DNS lookup to find a DC where the AD resides.

I used the DirectorySearcher.SearchRoot.Path to check if the path is set correctly for LDAP.

 

5> Now it’s time to set the filter properties of the DirectorySearcher with the LDAP query.

I’ll pass on the LDAP query to Configuration Manager AppSettings as the query will change from time-to-time.

 

6> Once everything is set, it’s time for the results. Results are captured using SearchResult with:

    • FindOne() – when fetching a specific user details with 1 results only. Something like in SDK we have IOrganizationService.Retrieve Method
    • FindAll() – when fetching multiple users with a filter criteria. Something like in SDK we have IOrganizationService.RetrieveMultiple Method 

 

 

7> Build the code and .exe is ready to be executed in the server. ?

The App.config file will be like this

 

8> And the final Result of query, if everything falls in place correctly.

 

Hope this was helpful. Thank much!  ?

 

Source: Ashwani Ashwin