SenseNet.DirectoryServices.SyncTree.GetADParentObjectPath C# (CSharp) Метод

GetADParentObjectPath() публичный Метод

public GetADParentObjectPath ( string objectADPath ) : string
objectADPath string
Результат string
        public string GetADParentObjectPath(string objectADPath)
        {
            // objectADPath pl.: LDAP://192.168.0.75/OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local

            string path = objectADPath;
            
            if (objectADPath.StartsWith(ServerPath))
                path = objectADPath.Substring(ServerPath.Length, objectADPath.Length - ServerPath.Length); //OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local

            string parentPath = path.Substring(path.IndexOf(",") + 1);

            // parent objektum path
            return parentPath;              //ExampleOrg,DC=Nativ,DC=local
        }

Usage Example

Пример #1
0
        // sync objects from AD to portal
        private void SyncObjectsFromAD(SyncTree syncTree,
                                       ADObjectType objType,
                                       SearchResultCollection allADObjects,
                                       Action <DirectoryEntry, string, Guid, SyncTree> CreateNewObject,
                                       Action <DirectoryEntry, Node, SyncTree> UpdateProperties)
        {
            foreach (SearchResult result in allADObjects)
            {
                try
                {
                    string nodeADpath = result.Path;

                    if (syncTree.IsADPathExcluded(nodeADpath))
                    {
                        continue;
                    }

                    AdLog.LogOuterADObject("Syncing", result.Path);

                    var guid = Common.GetADResultGuid(result, _config.GuidProp);

                    if (!guid.HasValue)
                    {
                        // no AD guid present for object
                        AdLog.LogErrorADObject("No AD GUID present", result.Path);
                        continue;
                    }

                    // új objektumok (ou, user, group) felvétele, átmozgatások
                    // - ha létezik az adott guid-ú objektum -> path ellenőrzés, átmozgatás
                    // - ha nem létezik, létrehozás

                    string nodePortalParentPath = syncTree.GetPortalParentPath(nodeADpath);
                    if (!Node.Exists(nodePortalParentPath))
                    {
                        // adpath: OU=OtherOrg,OU=ExampleOrg,DC=Nativ,DC=local
                        // portalParentPath: "/Root/IMS/NATIV/ExampleOrg"
                        EnsurePortalPath(syncTree, syncTree.GetADParentObjectPath(result.Path), RepositoryPath.GetParentPath(nodePortalParentPath));
                    }

                    SyncOneADObject(result, null,
                                    (Guid)guid,
                                    objType,
                                    nodePortalParentPath,
                                    CreateNewObject,
                                    UpdateProperties,
                                    syncTree);
                }
                catch (Exception ex)
                {
                    // syncing of one object of the current tree failed
                    AdLog.LogException(ex);
                }
            }
        }
All Usage Examples Of SenseNet.DirectoryServices.SyncTree::GetADParentObjectPath